Debounce @HostListener event

I would leverage debounce method decorator like: export function debounce(delay: number = 300): MethodDecorator { return function (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) { const timeoutKey = Symbol(); const original = descriptor.value; descriptor.value = function (…args) { clearTimeout(this[timeoutKey]); this[timeoutKey] = setTimeout(() => original.apply(this, args), delay); }; return descriptor; }; } and use it … Read more

Where is RxJS 6 static merge?

Importing has been made easy in RxJS 6: import { merge } from ‘rxjs’; You may want to read the official migration guide. Another useful resource regarding importing in RxJS 6 is this talk by Ben Lesh who is the RxJS lead.

How to force observables to execute in sequence?

If you want to be sure the order of emissions is the same as the order in which you specified the source Observables you can use concat or concatMap operators. The concat* operators subscribe to an Observable only after the previous Observable completes (it works with Promises as well, see http://reactivex.io/rxjs/class/es6/MiscJSDoc.js~ObservableInputDoc.html). In you case it’d … Read more

Check if object is an Observable

Since writing this answer, RxJS version 6 has been released and, in that version, an isObservable function was added to the public API. It can be imported like this: import { isObservable } from “rxjs”; The function signature is: export function isObservable<T>(obj: any): obj is Observable<T> Since it is defined with a typeguard, the compiler … Read more

RxJs – forkJoin with empty array

That’s because forkJoin requires all source Observables to emit at least one item and when there are no source Observables there’s nothing to emit. However, forkJoin will still send the complete notification so you can use for example defaultIfEmpty operator to make sure it always emits at least one next. forkJoin(observables).pipe( defaultIfEmpty(null), ).subscribe(…); Demo: https://stackblitz.com/edit/rxjs-kkd1qa?file=index.ts

Observable forkJoin not firing

forkJoin emits only when all inner observables have completed. If you need an equivalent of forkJoin that just listens to a single emission from each source, use combineLatest + take(1) combineLatest( this.statuses$, this.companies$, ) .pipe( take(1), ) .subscribe(([statuses, companies]) => { console.log(‘forkjoin’); this._countStatus(statuses, companies); }); As soon as both sources emit, combineLatest will emit and … Read more

Observable.throw replacement in rxjs 5.5.2

I’m still getting my head round 5.5 but it looks like now instead of importing throw use ErrorObservable. // import { _throw } from ‘rxjs/observable/throw’; import { ErrorObservable } from ‘rxjs/observable/ErrorObservable’; ErrorObservable.create(‘error’); From this guide it looks like it has to be _throw to avoid a keyword clash (the rest of the video is good … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)