Skip to content

Instantly share code, notes, and snippets.

View kievsash's full-sized avatar
💭
Be honest, be clever

Oleksandr kievsash

💭
Be honest, be clever
View GitHub Profile
@kievsash
kievsash / Notifications with noThrottling.js
Created January 26, 2019 11:17
Throttling notifications from multiple users with RxJS - no throttling
let Rx = window['rxjs'];
let {from, of, asyncScheduler} = Rx;
let {mergeMap, filter, delay} = Rx.operators;
console.clear();
let notifications = [
{ userId: 1, name: 'A1', delay: 100 }, // should be shown
{ userId: 1, name: 'A2', delay: 1500 }, // shouldn't be shown
{ userId: 1, name: 'A3', delay: 2500 }, // shouldn't be shown
{ userId: 1, name: 'A4', delay: 3500 }, // should be shown
@kievsash
kievsash / So how does Rx.js QueueScheduler actually work.js
Last active January 10, 2019 09:02
So how does Rx.js QueueScheduler actually work?
//value will be emitted at once — synchronously
of(1).subscribe(console.log)
//value will be emitted at once — synchronously
of(1, queueScheduler).subscribe(console.log)
// value will be emitted in mIcrotask just after current mAcrotask
of(1, asapScheduler).subscribe(console.log)
// value will be emitted in another mAcrotask
@kievsash
kievsash / 'of' with observeOn + asyncScheduler.js
Last active October 26, 2018 10:32
'of' with observeOn + asyncScheduler
let Rx = window['rxjs'];
const {of,
queueScheduler,
asapScheduler,
asyncScheduler,
animationFrameScheduler
} = Rx;
const {observeOn, tap} = Rx.operators;
console.clear();
@kievsash
kievsash / argument scheduler.js
Created October 26, 2018 10:24
rx.js, 'of' argument scheduler
let Rx = window['rxjs'];
const {of,
queueScheduler,
asapScheduler,
asyncScheduler,
animationFrameScheduler
} = Rx;
const {observeOn, tap} = Rx.operators;
console.clear();
@kievsash
kievsash / Conditional Retry logic in Rx.JS in 5 minutes.md
Last active August 11, 2018 04:52
#ReactiveConf 2018 Lightning Talk Proposal: Conditional Retry logic in Rx.JS in 5 minutes!

This is a my proposal for lightning talk at Reactive Conf 2018. Please ⭐️ if you want to listen to it!

ReactiveConf 2018

Conditional Retry logic in Rx.JS in 5 minutes!

Hello Every-buddy! I am Oleksandr, front-end developer in http://tonicforhealth.com/

In this lightning talk I want to share my experience in using Rx.JS retry operator when you need to customize its behaviour for specific Observable error. it is a shortened version of my speech on JS-FW-days conference in Ukraine.

@kievsash
kievsash / delay notif.js
Created July 31, 2018 12:33
distinctUntillChanges delay notification for same user but not for others
let usersToDelay = {}
action$
.ofType(OPEN_NOTIFICATION)
.distinctUntilChanged( (prev, next) => {
let userName = next.userName;
if (usersToDelay[userName]) {
return true; // do not emit notification
}
setTimeout(() => {delete usersToDelay[userName];}, 3000);