Welcome to an episode of Duck Tapes Quick Quacks, with your host John Haupenthal.
This week is the introduction of Quick Quacks aka shorter episodes that I can put out while I'm busy with project work. Today I go over and awesome state management library that makes using redux feel like you're not using redux: Rematch! Also I FINALLY reveal my favorite Nirvana song (I got tired of being harassed on Twitter).
John:
Welcome to an episode of Duck Tapes Quick Quacks. I'm your host as always, John Haupenthal. I have been pretty busy with projects lately. That combined with the fact that I don't have any interviews lined up has forced me, well not forced me, but kind of made me decide to make these new Quick Quacks episodes as a way to still feed the rabid Duck Tapes fan base. I hear the two of you. Don't worry, I am not going anywhere.
There won't really be any format to these episodes. The only identifying characteristic is that they will be short. I guess probably a secondary identifying characteristic ... Did I say secondary funny right there? Isn't that funny when you say a word and in your head you realize that you mispronounced it or pronounced it just weird, and you keep moving on in the conversation, and you know that everybody else heard it, but it's just awkward to acknowledge?
Anyway, what was I saying? Oh, another characteristic that will surely come out of the woodwork will be that these episodes will inevitably be unsatisfying. So hopefully you can hear my children screaming in the background. Adding to the fact that I am very busy with work, I also have two young children who for the last few days have been under the weather. So that is super fun too, runny noses all around. So if I sneeze in the middle of this, that's why.
See, aren't these episodes great? So far I've talked about nothing of interest. But something that I do want to talk about that I think duck heads everywhere will be interested in is a library called Rematch, which I am currently in love with. Don't tell my wife.
So Rematch makes using Redux easy and enjoyable, and I cannot say it makes using Redux easy and enjoyable again because let's be honest, while Redux is great, it was never enjoyable. It becomes easy after a while, but there is just so much boiler plate and so many things that you have to do to accomplish basic results that it just gets tiring after a while.
So I was recently introduced to Rematch on a project at work, and it essentially lets you write Redux without the million lines of code that you would typically need to do something basic like increment the count in your store. There is zero boiler plate. Your reducer actions and types are all combined into a file called a model, and a model contains your state, your reducer and actions all in the same object, and actions are redefined as something called effects, which are releasing methods that you can define on any model.
So already, right, this sounds super cool. You don't need a file for actions. You don't need a file for types. You just need essentially to rename your reducer file as a model and then add your actions as a third argument of your model object.
Some of the cool stuff that I really like is that it makes it super easy for reducers to interact with each other. So within your effects that are in every model, you have access to the entire rootState. That means that you can access another model's state as well as another model's actions.
So, for example, if you had two models, one called user and one called, I don't know, coupons, say you're making a coupon app, right? So your coupon app can show coupons to all users and then a different subset of coupons to users that are logged in.
So what would happen is that you would launch the app, your coupon model would fetch all the regular coupons, and then sometime later within the app if a user logged in using the user model, you could dispatch an action to fetch user coupons, and that action would be defined over in your coupons model. You don't have to import anything. You just dispatch it from your user effects. You have access to all other effects and state all across your models. It's super duper easy.
On top of that, there are some really helpful default plug-ins that you can import and enable. One is a loading plug-in, which once enabled adds a loading property to your store. Within that loading property there is a key for every effect that is defined across all of your models. Within each of those effects in your loading property in your store, it has a loading bullion.
So now any component or any effect or anywhere in your app, you can access whether an async action is in the process of functioning. I'm eating my words there, but you know what I mean. You can detect if anything is running just by using this loading plug-in. To use it, you just import it and add it as a property on your store that you define. There is nothing else you need to do, and it automatically adds the new effects as you define them.
So once you enable the loading plug-in, that's all you need to do. Every action that you write now will have a key within that loading plug-in. They also have a persist plug-in that makes it super easy to define what parts of your store you want to persist, which is super cool. Let's see.
One final thing. Rematch makes it simple to integrate with TypeScript. With a few lines of code, you can define types for your store and actions, and those types will dynamically update as you update your models. So once you type in these few lines of code anywhere within your app, when you start typing like rootState.user, it'll auto complete what your properties are on that model. It's super duper cool.
So I will link in the show notes to the Rematch library. I highly, highly recommend checking it out. After using it, I went back to another project that had good old fashioned Redux, and I had to add one reducer and one property to that producer, and it was just more lines of code than I would have preferred. So check out rematch. Super neat.
So what are we? Oh my God, we're already eight minutes deep, and this is a Quick Quack episode. Oh my gosh. Isn't this fun? So one other thing that I want all you duck heads to know about is my favorite Nirvana song. Why do I want you to know? Well, because Nirvana has been my favorite band forever. My favorite song from them is a song that I feel like is probably not super well known and definitely underappreciated.
It's a song called D-7. It originally was released on a six-song EP that they sold during their 1992 tour in Japan and Australia. So initially it was very difficult to get access to this song. The EP was called Hormoaning, if anybody cares, and it contained, I think, four covers and two original songs. D-7 is a cover. The original band that put it out is called The Wipers, but like with many Nirvana covers, they took it and sort of made it their own.
I really love the song for, I mean, a multitude of reasons. I've heard it 100,000 times at this point. I've been listening to it since I was 13. It starts off with a really haunting, sparse and pretty slow opening guitar riff, and the singing is very restrained and quiet. You kind of think, why does Nirvana really sing this song? They're sort of known for being loud and angry, and this is just not what I would expect.
Then at 1:33, mark that time, 1:33, Dave Grohl just starts building this crescendo on his cymbal, and you just know that this song is about to go insane. I love any song that has an initial melody and music part that's played quiet and slow and then ramps it up and makes it nutty. That's what this song does to the nth degree.
So it's great. They just start playing it like a punk song. Kurt Cobain's, his wail after the gnarly guitar solo is arguably one of his most visceral on record. It always blows me away. You can just feel the anger seeping through the speakers, and for the remainder of the song while he's singing, you can hear that his throat is a little bit shredded from that wail. That sort of intensity is one of the reasons that I fell in love with Nirvana.
The lyrics, while they are not Kurt's, are still similar to what a lot of Nirvana songs tended to do, which was have sort of ambiguous lyrics that somehow seemed understandable, if that makes any sense. You can sense that the lyrics are about feeling alienated and different and why that isn't a bad thing.
So yeah, check it out, all you young teenagers out there that are listening to this. I know there are none of you. Let's see. Oh, I guess building off of that, I also just finished a book called Serving the Servants, which was written by Nirvana's manager during their short three years of being the biggest band in the world from 1992 to 1994, which is always so crazy to think about that they were really only famous for that short period of time before he killed himself. It's a super interesting look behind the scenes of what was going on in Kurt and the band's life.
So if you are into Nirvana or the grunge scene or music history at all, I highly recommend picking it up. It's a short, breezy read, and there's a lot of really good stuff in there. Okay, well that's it for Quick Quacks. What'd you guys think of this episode? Tweet at me. Let me know. I will keep doing these episodes regardless of what is said, just because I want to keep putting out content, and finding people to interview is not as easy as you would think.
Hey, if anybody wants to be interviewed, let me know. Tweet at me about anything. Tech, music, I don't know, cooking, whatever your hobbies are. I'll talk to anybody. I don't mean that to sound desperate. I just mean this podcast is fun, so let's get some more content, guys. Wow, that sounded pretty pathetic. Alrighty. Thanks, everybody. Follow @ducktapesfm on Twitter for a maybe biweekly tweet, and then follow me on Twitter at John-
Speaker 2:
Powered by Visit Quack Quack.