Posts

Showing posts with the label mixins

Flight Mixins Are Awesome!

OK, OK, probably is just that I cannot wait to start writing stuff with [tinydown](https://github.com/WebReflection/tinydown#tinydown) but I tweeted about this after last #FlightNight and @angustweets demo ... so here what is behind [Flight](http://twitter.github.io/flight/) mixins choice. ### The Basics JavaScript polymorphism is probably one of the best things you can find out there. Not kidding, the flexibility that this language offers when it comes to context injection and runtime class definition is simply amazing, as simple, and amazing, is this idea: ```js // most basic example function enriched() { this.method = function () { // do stuff }; } ``` Most common books and online documents usually describe above example as a _constructor with privileged methods_. Well, that's actually what you get if you `var obj = new enriched();` but that's just one story. Flight uses a different story, offering alternative methods with better semantics but basically going down to...