Created
December 22, 2017 16:40
-
-
Save vivainio/b5f936a69d22a13aa933256877f72e0f 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
| // don't like patching your components with custom hacks? use this! | |
| class MobWrap { | |
| unsubs: (() => void)[] = []; | |
| constructor() {} | |
| autorun(view: (r: IReactionPublic) => any, scope?: any) { | |
| this.unsubs.push(realAutorun(view)); | |
| // "fluent" api for chaining stuff | |
| return this; | |
| } | |
| reaction<T>( | |
| expression: (r: IReactionPublic) => T, | |
| effect: (arg: T, r: IReactionPublic) => void, | |
| opts?: IReactionOptions | |
| ) { | |
| this.unsubs.push(realReaction(expression, effect, opts)); | |
| return this; | |
| } | |
| stop() { | |
| this.unsubs.forEach(f => f()); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment