Skip to content

Instantly share code, notes, and snippets.

@shivenigma
Created August 13, 2020 15:06
Show Gist options
  • Save shivenigma/bf3484f021aaaf8a1ff695531d67928b to your computer and use it in GitHub Desktop.
Save shivenigma/bf3484f021aaaf8a1ff695531d67928b to your computer and use it in GitHub Desktop.
Used in blog post
import { Observable } from 'rxjs';
const greeting$ = new Observable(observer => {
const clear = setInterval(() => {
observer.next('Hello, there');
}, 1000);
// Need to handle the interval here, otherwise you'll end up in a infinitely firing observable.
});
greeting$.subscribe(res => {
console.log(res);
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment