How to detect rxjs related memory leaks in Angular apps

Disclaimer: I’m the author of the tool I mention below. This can be accomplished by keeping a list where new subscriptions are added to, and removing subscriptions from this list once it is unsubscribed. The troublesome part is observing subscriptions. A straightforward way to achieve this is by monkey-patching the Observable#subscribe() method, that is, replacing … Read more

Error: : fromEvent is not declared writable or has no setter

You need to spy on a property of rxjs. Using spyOnProperty will solve the error. Try this import * as rxjs from ‘rxjs’ import { of, fromEvent } from ‘rxjs’; spyOnProperty(rxjs, ‘fromEvent’).and.returnValue(of({})) you can also add to getter/setters using this like spyOnProperty(rxjs, ‘fromEvent’, ‘get’).and.returnValue(false) Hope this helps

Why would I use RxJS interval() or timer() polling instead of window.setInterval()?

Advantage of RxJS: Laziness You can create your Observables and until you call subscribe nothing is happening. Observable = pure function. This gives you more control, easier reasoning and allows for next point… Composability You can combine interval/timer with other operators creating custom logic very easily in unified way – for example you can map, … Read more

Angular : how to call finally() with RXJS 6

use throwError instead of Observable.throw, see https://github.com/ReactiveX/rxjs/blob/master/docs_app/content/guide/v6/migration.md#observable-classes finally was renamed to finalize and you’ll use it inside pipe() among other operators. the same with publish() and refCount(). Both are operators you’ll use inside pipe().

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.

combineLatest deprecated in favor of static combineLatest

In rxjs 6.5+ import { combineLatest } from ‘rxjs’; combineLatest([a$, b$, c$]); And for most applications it’s helpful to map the array of observables to a new value as well: combineLatest([a$, b$, c$]).pipe( map(([a$, b$, c$]) => ({ a: a$, b: b$, c: c$ })) ); Also see: https://www.learnrxjs.io/learn-rxjs/operators/combination/combinelatest

Angular/RxJS 6: How to prevent duplicate HTTP requests?

After trying a few different methods, I came across this one that resolves my issue and only makes one HTTP request no matter how many subscribers there are: class SharedService { someDataObservable: Observable<any>; constructor(private http: HttpClient) {} getSomeData(): Observable<any> { if (this.someDataObservable) { return this.someDataObservable; } else { this.someDataObservable = this.http.get<any>(‘some/endpoint’).pipe(share()); return this.someDataObservable; } } … Read more

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