Skip to content

Instantly share code, notes, and snippets.

@Mayankgupta688
Last active April 24, 2019 10:48
Show Gist options
  • Save Mayankgupta688/31814ee90c1065223158e743e162cef4 to your computer and use it in GitHub Desktop.
Save Mayankgupta688/31814ee90c1065223158e743e162cef4 to your computer and use it in GitHub Desktop.
import { Observable } from 'rxjs';
var randomNumberGenerator = Observable.create(function(observer) {
setTimeout(function() {
var randomNumber = Math.floor(Math.random() * 100);
if(randomNumber == 13) {
observer.error("Incorrect Random Number Generated");
} else if(randomNumber == 99) {
observer.complete();
} else {
observer.next(randomNumber);
}
}, 1000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment