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

retry and catch ? #5

Open
Sinewyk opened this issue Jun 8, 2016 · 2 comments
Open

retry and catch ? #5

Sinewyk opened this issue Jun 8, 2016 · 2 comments

Comments

@Sinewyk
Copy link
Contributor

Sinewyk commented Jun 8, 2016

retry and catch aren't in the tables (coming from RxJs).

You can't retry a Promise, but just map strings to http requests that returns an observable that you call retry on and catch, and you have powerful error handling.

I can't find or am not experienced enough yet to do a similar stuff with most.

Help ? 😄

@ivan-kleshnin
Copy link
Owner

ivan-kleshnin commented Jun 8, 2016

PRs are welcomed :) I'm out of time a.t.m. unfortunately.

MostJS has super friendly community so you can ask (in gitter) whatever question you have (even the most stupid one) and expect for a thorough answer. I know – I did ;)

@Sinewyk
Copy link
Contributor Author

Sinewyk commented Jun 8, 2016

from gitter and @briancavalier

retry (works):

const retry = (n, stream) =>
  stream.recoverWith(e => n === 0 ? most.throwError(e) : retry(n - 1, stream))

catch:

stream$
.recoverWith(err => {
  // handle error and return new stream
  // or do not handle error and rethrow with most.throwError(err);
})

will probably come with a PR extending the quick response.

edit: simplified catch case

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

2 participants