Skip to content

Instantly share code, notes, and snippets.

@kievsash
Last active October 26, 2018 10:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kievsash/de5127dc23cbc8d5148becb9db8a4a20 to your computer and use it in GitHub Desktop.
Save kievsash/de5127dc23cbc8d5148becb9db8a4a20 to your computer and use it in GitHub Desktop.
'of' with observeOn + asyncScheduler
let Rx = window['rxjs'];
const {of,
queueScheduler,
asapScheduler,
asyncScheduler,
animationFrameScheduler
} = Rx;
const {observeOn, tap} = Rx.operators;
console.clear();
setTimeout(() => console.log('It will runs just after this Macrotask'))
let source$ = of(1, 2, 3).pipe(
tap((v) => console.log('tap ', v)),
observeOn(asyncScheduler)
)
source$.subscribe((v) => {
console.log('Value ', v);
Promise.resolve().then(() => console.log('Microtask value ', v));
setTimeout(() => console.log('MAcrotask value ', v), 0);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment