Skip to content

Commit

Permalink
run function receives all sources streams
Browse files Browse the repository at this point in the history
BREAKING CHANGE

in case you want to listen to more than just future actions, this change
allows your app `run` function to listen to any source stream returned
by `inu.start`.
  • Loading branch information
ahdinosaur committed Jun 23, 2016
1 parent ae11b55 commit f339622
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
22 changes: 12 additions & 10 deletions start.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,20 @@ function start (app) {
)

var effectActionStreams = notify()

var streams = {
actions: actions.listen,
states: states.listen,
models: models.listen,
views: views.listen,
effects: effects.listen,
effectActionStreams: effectActionStreams.listen
}

pull(
effects.listen(),
pull.map(function (effect) {
return run.call(app, effect, actions.listen)
return run.call(app, effect, streams)
}),
pull.filter(isNotNil),
pull.drain(effectActionStreams)
Expand All @@ -87,15 +97,7 @@ function start (app) {
states(initialState)
})

return {
stop: stop,
actions: actions.listen,
states: states.listen,
models: models.listen,
views: views.listen,
effects: effects.listen,
effectActionStreams: effectActionStreams.listen
}
return Object.assign({}, streams, { stop: stop })

function stop () {
;[
Expand Down
3 changes: 2 additions & 1 deletion test/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ test('actions stream passed to run emits actions', function (t) {
view: function (model, dispatch) {
return inu.html`<div></div>`
},
run: function (effect, actions) {
run: function (effect, streams) {
const actions = streams.actions
pull(actions(), pull.take(1), pull.drain(function (action) {
t.equal(action, expectedAction)
t.end()
Expand Down

0 comments on commit f339622

Please sign in to comment.