Skip to content

Instantly share code, notes, and snippets.

@kuy
Last active January 11, 2017 03:18
Show Gist options
  • Save kuy/743ba0a67b31c101c53d0f61c2cbe897 to your computer and use it in GitHub Desktop.
Save kuy/743ba0a67b31c101c53d0f61c2cbe897 to your computer and use it in GitHub Desktop.
take event from multiple channels
// From https://github.com/kuy/redux-tower/commit/9619bb7f65f147640ee8e15ecc8d26dae1b537fd#diff-f38699c88139ae09699a6830074a2af5R30
function takeFromChannels(channels) {
return race(
Object.keys(channels)
.map(name => ([name, channels[name]]))
.reduce((prev, [name, ch]) => ({ ...prev, [name]: take(ch) }), {})
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment