Skip to content

Instantly share code, notes, and snippets.

@jamestthompson3
Created June 3, 2018 09:40
Show Gist options
  • Save jamestthompson3/506b136a0aee1a044d3e0516faf63f65 to your computer and use it in GitHub Desktop.
Save jamestthompson3/506b136a0aee1a044d3e0516faf63f65 to your computer and use it in GitHub Desktop.
const modalHandler = mapPropsStream(props$ => {
const { stream: isOpen$, handler: toggleModal } = createEventHandler()
return props$.pipe(
switchMap(props =>
isOpen$.pipe(
startWith(false),
scan(bool => !bool),
map(isOpen => ({ ...props, isOpen, toggleModal }))
)
)
)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment