yoshuawuyts / barracks

:mountain_railway: action dispatcher for unidirectional data flows
MIT License
177 stars 22 forks source link

expose .on and .emit after initialization #21

Closed yoshuawuyts closed 9 years ago

yoshuawuyts commented 9 years ago

not recommending to do things dynamically, but being able to pass around an instance is neat.

yoshuawuyts commented 9 years ago

Removes the need for a large up-front object of requirements

yoshuawuyts commented 9 years ago

possibly leverage the .on('foo:bar:bin:baz', () =>) shiz; or just .on('foo:bar', () =>)

yoshuawuyts commented 9 years ago
const barracks = require('barracks')

const d = barracks()
d.on('courses:get', () => console.log('whoop!')
d.on('courses:post', (ev, data, wait) => wait(['foobar', 'binbaz']))

d('courses:post', {my: 'data'})
yoshuawuyts commented 9 years ago
yoshuawuyts commented 9 years ago

could also turn wait into an object with yieldable values. E.g. going the co route

yoshuawuyts commented 9 years ago

Or just make wait return a Promise, so it can be yielded through Babel. Mwhehhhhh

yoshuawuyts commented 9 years ago

Should also be infinitely nestable, like with wayfarer.

yoshuawuyts commented 9 years ago

We should probably leverage mounting semantics as outlined in https://github.com/yoshuawuyts/wayfarer/issues/12, making this the data transport counterpart to wayfarer.

yoshuawuyts commented 9 years ago

Closed in 138aeac