Promise Anti-patterns
Promises are very simple once you get your head around them, but there are a few gotchas that can leave you with your head scratching. Here are a few that got me.Nested PromisesYou get a whole bundle...
View ArticleStudying the Angular JS Injector - intro
I am truly impressed with the elegance of AngularJS and have been studying the source code to fully understand it. In this series I will be studying the Injector module as this is one of the core...
View ArticleStudying the Angular JS Injector - annotate
(This post is part of a series studying the AngularJS injector)In order for the Injector to know what to inject into a given functions parameters, it needs a list of these parameters. This is what the...
View ArticleStudying the Angular JS Injector - instantiate
(This post is part of a series studying the AngularJS injector)Whilst invoke calls a function with it’s parameters injected, instantiate will contruct a new object with it’s constructor parameters...
View ArticleStudying the Angular JS Injector - invoke
(This post is part of a series studying the AngularJS injector)The invoke method invokes the given function with the parameters injected.function invoke(fn, self, locals){ var args = [], $inject =...
View ArticleStudying the Angular JS Injector - getService
(This post is part of a series studying the AngularJS injector)The getService function is the work-horse of invoke. This is the method that takes a service name and attempts to locate it in the list of...
View ArticleStudying the Angular JS Injector - the twin injectors
(This post is part of a series studying the AngularJS injector)When Angular creates the injector, it actually creates two injectors:providerInjector = (providerCache.$injector =...
View ArticleStudying the Angular JS Injector - loading modules
(This post is part of a series studying the AngularJS injector)A module gets loaded with the following code: function loadModules(modulesToLoad){ var runBlocks = [], moduleFn, invokeQueue, i, ii;...
View ArticleJavascript Schönfinkeling
In Javascript is it extremely common to pass function as parameters to other functions.function addOne(a) { return a + 1; } [1,2,3,4].map(addOne); This is all good. However when your function takes...
View ArticleCreating a plugin system in Angular JS with the $compile service
Angular JS directives are powerful. Using them allows you to manipulate pretty much everything in the DOM that you would want to. But there is one exception. Dynamically creating a directive depending...
View ArticleCond and friends
There are a number of different cond’s in Clojure.condThe classic cond. This replaces the standard if...else if....else that you find in other languages. It takes a set of test and expression pairs....
View ArticleOn Triangles
In SICP 1.2.2 Tree Recursion we have Exercise 1.12 which asks us to code up a recursive solution to compute the elements of Pascals Triangle. 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 Pascals Triangle has two...
View Article