Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce side-effects on error/complete #403

Open
xareelee opened this issue Jan 26, 2017 · 3 comments
Open

Introduce side-effects on error/complete #403

xareelee opened this issue Jan 26, 2017 · 3 comments

Comments

@xareelee
Copy link

I found that tap only supports next event of the streams.

How do I introduce side-effects on error/complete events?

@briancavalier
Copy link
Member

Hi @xareelee. Error and end can be observed (and thus perform side-effects) via the promise returned by observe, drain, or reduce.

import { throwError, empty } from 'most'

const s1 = throwError(new Error('error stream'))

s1.drain()
 .catch(e => console.error('errored', e.stack))

const s2 = empty()

s1.drain()
 .then(() => console.log('ended'))

You can also use continueWith and recoverWith to replace the end and error signals with more events.

@xareelee
Copy link
Author

@briancavalier

It seems that I can't introduce side-effects for error/complete like tap per subscription. doesn't it?

@Sinewyk
Copy link
Contributor

Sinewyk commented Mar 21, 2017

If you can tap your stream stream, you can continueWith/recoverWith just before subscribing to it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants