Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>bufferCount</title>
  <script src="https://npmcdn.com/@reactivex/rxjs@5.0.0-beta.3/dist/global/Rx.umd.js"></script>
</head>
<body>
</body>
</html>
 
// custom error handling logic
const retryThreeTimes = obs => obs.retry(3).catch(_ => Rx.Observable.of('ERROR!'));
const examplePromise = val => new Promise(resolve => resolve(`Complete: ${val}`));
//faking request
const subscribe = Rx.Observable
    .of('some_url')
  .mergeMap(url => examplePromise(url))
  // could reuse error handling logic in multiple places with let
  .let(retryThreeTimes)
  //output: Complete: some_url
  .subscribe(result => console.log(result));
const customizableRetry = retryTimes => obs => obs.retry(retryTimes).catch(_ => Rx.Observable.of('ERROR!'));
//faking request
const secondSubscribe = Rx.Observable
    .of('some_url')
  .mergeMap(url => examplePromise(url))
  // could reuse error handling logic in multiple places with let
  .let(customizableRetry(3))
  //output: Complete: some_url
  .subscribe(result => console.log(result));
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers