Skip to content

Instantly share code, notes, and snippets.

@jamestthompson3
Last active May 13, 2018 08:06
Show Gist options
  • Save jamestthompson3/78b4029c395f3277b0a6808dd153f96f to your computer and use it in GitHub Desktop.
Save jamestthompson3/78b4029c395f3277b0a6808dd153f96f to your computer and use it in GitHub Desktop.
const load = mapPropsStream(props$ =>
props$.pipe(
switchMap(props =>
from(fetchUsers()).pipe(
tap(res => console.log('response from fetchUsers', res),
map(users => ({ ...props, users, status: 'SUCCESS' })),
startWith({ status: 'REQUEST' })
)
),
catchError(() => ({ status: 'ERROR', message: 'Looks like our service is down' }))
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment