Created
April 24, 2020 13:41
-
-
Save NyaGarcia/56c1d0947c53f4c44dc427d3ee0ebb49 to your computer and use it in GitHub Desktop.
Creating Observables with interval()
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 { interval } from "rxjs"; | |
// Observable will emit incremental numbers, one every second (1000ms) | |
const number$ = interval(1000); | |
// We didn't pass the interval size parameter, so default value is 0ms | |
const superFastNumber$ = interval(); | |
number$.subscribe(console.log); | |
// Output: 0 1 2 3 4 5... | |
// Careful with this one, it will emit numbers very very quickly | |
superFastNumber$.subscribe(number => console.log(number)); | |
// Output: O 1 2 3 4 5 6 7 8 9... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment