Last active
February 24, 2018 22:35
-
-
Save btakita/bea0f1b039b90eae556317b3119833a0 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
| agent__xyz(ctx).on('change', (ctx) => { | |
| const {x,y,z} = ctx | |
| }) | |
| agent__a(ctx).set({a:1}) | |
| function agent__xyz(ctx) { | |
| let agent = ctx.agent__xyz | |
| if (agent) return agent | |
| return ensure__agent(ctx, { | |
| key: 'agent__xyz', | |
| scope: ['x', 'y', 'z'], | |
| init() { | |
| agent = this | |
| agent__a(ctx).on('change', agent.reset) | |
| }, | |
| async reset() { | |
| const {a} = ctx | |
| , everything = await everything__async() | |
| , z = a + 1 + everything | |
| , y = z + 1 + everything | |
| , x = y + 1 + everything | |
| agent.set({x, y, z}) | |
| } | |
| }) | |
| async function everything__async() { | |
| return 42 | |
| } | |
| } | |
| function agent__xyz(ctx) { | |
| let agent = ctx.agent__xyz | |
| if (agent) return agent | |
| return ensure__agent(ctx, { | |
| key: 'agent__a', | |
| scope: ['a'] | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment