Last active
April 24, 2019 10:48
-
-
Save Mayankgupta688/31814ee90c1065223158e743e162cef4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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