-
-
Save BCdmlap/3132606 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Check out http://craig.is/killing/mice for another project that is describing dependencies between async tasks. | |
*/ | |
- (void)setupSetVideoListener | |
{ | |
BCFlowChain *chain = [BCFlowChain chain]; | |
setVideoListener = [emitter on:BCEventSetVideo callBlock:^(BCEvent *setVideoEvent){ | |
[chain reset]; | |
[chain abortOn:BCEventSetVideo]; | |
[chain emit:BCEventShouldSetVideo]; | |
[chain thenDo:^(BCEvent *shouldSetVideoEvent){ | |
if (shouldSetVideoEvent.defaultPrevented) { | |
[chain emit:BCEventCancelledSetVideo parentEvent:setVideoEvent]; | |
[chain thenAbort]; | |
} | |
}]; | |
[chain emit:BCEventWillSetVideo parentEvent:setVideoEvent]; | |
[chain emit:BCEventSetRendition withDetails: | |
[NSDictionary dictionaryWithObject:rendition forKey:@"rendition"]]; | |
[chain emit:BCEventSetVideoStill withDetails: | |
[NSDictionary dictionaryWithObject:videoStill forKey:@"videoStill"]]; | |
[chain waitForBoth:BCEventDidSetRendition and:BCEventDidSetVideoStill]; | |
[chain thenDo:^{ | |
self.video = [setVideoEvent.details objectForKey:@"video"]; | |
[chain emit:BCEventDidSetVideo parentEvent:setVideoEvent]; | |
}]; | |
}]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment