(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
State machines are everywhere in interactive systems, but they're rarely defined clearly and explicitly. Given some big blob of code including implicit state machines, which transitions are possible and under what conditions? What effects take place on what transitions?
There are existing design patterns for state machines, but all the patterns I've seen complect side effects with the structure of the state machine itself. Instances of these patterns are difficult to test without mocking, and they end up with more dependencies. Worse, the classic patterns compose poorly: hierarchical state machines are typically not straightforward extensions. The functional programming world has solutions, but they don't transpose neatly enough to be broadly usable in mainstream languages.
Here I present a composable pattern for pure state machiness with effects,
// | |
// Created by ddrccw on 14-1-10. | |
// Copyright (c) 2014年 ddrccw. All rights reserved. | |
// refer to http://danqingdani.blog.163.com/blog/static/1860941952012102122847478/ | |
#import <sys/stat.h> | |
#import <mach-o/dyld.h> | |
//#import <stdlib.h> | |
//#import <string.h> |
// Promise.all is good for executing many promises at once | |
Promise.all([ | |
promise1, | |
promise2 | |
]); | |
// Promise.resolve is good for wrapping synchronous code | |
Promise.resolve().then(function () { | |
if (somethingIsNotRight()) { | |
throw new Error("I will be rejected asynchronously!"); |
It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.
var FadeTransitionRegion = Backbone.Marionette.Region.extend({ | |
show: function(view){ | |
this.ensureEl(); | |
view.render(); | |
this.close(function() { | |
if (this.currentView && this.currentView !== view) { return; } | |
this.currentView = view; |
@interface PSPDFWindow () | |
@property (nonatomic, strong) UIViewController *realRootViewController; | |
@end | |
@implementation PSPDFWindow | |
- (void)setHidden:(BOOL)hidden { | |
[super setHidden:hidden]; | |
// Workaround for rdar://19592583 |