Skip to content

Instantly share code, notes, and snippets.

@Sinewyk
Last active June 19, 2017 03:26
Show Gist options
  • Save Sinewyk/5151704960c76f47dad38c28433df4b2 to your computer and use it in GitHub Desktop.
Save Sinewyk/5151704960c76f47dad38c28433df4b2 to your computer and use it in GitHub Desktop.
const set = [0, 1, 2];
const retry = n => stream => stream.recoverWith(e => n === 0 ? most.throwError(e) : retry(n - 1, stream));
let i = 0;
most.from(set)
.tap(x => {
if (i === 0 && x === 2)
{
i++;
throw new Error('2 !')
};
})
.thru(retry(1))
.observe(x => console.log(x))
.then(() => console.log('complete'))
.catch(err => console.error(err));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment