Skip to content

Instantly share code, notes, and snippets.

@marcusradell
Created November 17, 2016 14:56
Show Gist options
  • Save marcusradell/58e095ae698e09c359bf9a9b2f6972dc to your computer and use it in GitHub Desktop.
Save marcusradell/58e095ae698e09c359bf9a9b2f6972dc to your computer and use it in GitHub Desktop.
rxjs select stream
export default function create({
Observable,
gridSelectStream,
newEntityResolveStream,
entityStoreStateStream
}) {
const newEntitySelectStream = newEntityResolveStream
.switchMap(function onSwitchMap(eventData) {
return entityStoreStateStream
.filter(function onFilter(entityStoreStateData) {
return entityStoreStateData.items[eventData.id]
})
.map(function onMap(entityStoreStateData) {
return {
id: eventData.id,
item: entityStoreStateData.items[eventData.id]
}
})
.take(1)
})
return Observable
.merge(
gridSelectStream,
newEntitySelectStream
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment