Skip to content

Instantly share code, notes, and snippets.

@ChrisMoney
Created June 9, 2024 14:11
Show Gist options
  • Save ChrisMoney/b60dac0c522b41ef8f99714c8dea4269 to your computer and use it in GitHub Desktop.
Save ChrisMoney/b60dac0c522b41ef8f99714c8dea4269 to your computer and use it in GitHub Desktop.
Observable - Javascript
/* Observables allow you to track changes or data over time,
rather than just waiting for a single result like with promises.
*/
// Create an Observable that emits a value every second
const observable = Rx.Observable.interval(1000);
// Subscribe to the Observable and print the emitted values to the console
observable.subscribe(value => console.log(value));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment