You know, there’s this one thing that has always driven me crazy about blogs.
You see, too often, whenever they explain how to do something, they’ll give you the basics. They step through “Hello, World”, and that’s it. But you find yourself wanting to do something more complicated, and you find yourself flitting through twenty “Hello, World” tutorials hoping to find more insight. As a musician, I can say that it’s one thing to learn musical scales, but it’s quite another thing to know songs in those scales or when it’s the right time to use them. With this post, I want to go a couple steps further. Promises are a great tool, but their purpose is to solve problems, not just get you past interviews (or provide cheap blog post fodder).
Okay, this’ll be quick. This article is just for those using Angular, especially those versions before Angular 2. I figure that even if the entire world stopped writing new apps in Angular, there would still be a metric pantload of legacy apps to maintain. This article assumes enough familiarity with Angular to create controllers and services. The reason I’m writing this article is that Angular has one particular quirk about timing: dirty-checking. You can’t just change data; you gotta tell Angular you did it so that it can go through the laborious task of updating the view.
I don’t know what your familiarity level is with functional programming, and I’m not planning to go too far into it. I’m currently taking a specialization on the subject on Coursera, but if you’re totally new to the concept, I would really recommend the YouTube channel Fun Fun Function by Mattias Petter Johansson (a.k.a. mpj). He breaks down the basics of functional programming reeeeeeaally well. For now we’re going to do what functional programming does best: compose.
In a previous post, I introduced the idea of promises and the purpose they serve, while also delivering an ode to nachos, a paean on a pan, as it were. This time, I actually want to get to the nitty gritty, and demonstrate how to create, transform, and combine promises in the new ES6 syntax. I’ll follow up with the same article in the syntax more common to Angular.JS, since that’s where most of my work has been.
It has been said of history that it’s “just one damned thing after another.” (By the way, that’s the title of a fantastic book about time travel by Jodi Taylor, and I can’t recommend it enough). The way we tell the story of history is often very sequential. An archduke is shot in Sarajevo, the Central Powers start a war, yada, yada, yada. But this telling hides a very complicated web of events that encapsulates trade agreements, royal marriages, personal affronts, and a regressive genetic defect called the “Hapsburg Jaw”.
Yes, I know writing a blog post about making the blog on with post is hosted is maybe a little bit too meta. But how we do anything that we would associate with ourselves should merit some reflection, and I have to blog about something, right?
Problem solving. It’s so easy to think of it as the ability to exert control over every situation. But what is it really, and how can we learn to do it better?