天道酬勤,学无止境

rxjs6

Why rxjs debounceTime does not work on observables created using 'of' operator?

Using angular 7 and rxjs 6: <input (input)="onChange($event.target.value)"> Why the following does not debounce? onChange(val: string) { of(val) .pipe( debounceTime(300) ).subscribe(valx => { console.log(valx); }); } But this does: searchTerm$: Subject<string> = new Subject(); this.searchTerm$.pipe( debounceTime(300), ).subscribe(val => { console.log(val); }); onChange(val: string) { this.searchTerm$.next(val); }

2022-04-29 05:56:19    分类:问答    angular   rxjs   rxjs6   debouncing

error TS2339: Property 'takeUntil' does not exist on type 'Observable<Foo>' and other rxjs v.6 errors

I just recently updated A LOT of packages in my angular project. Old package.json: { "name": "data-jitsu", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^5.2.10", "@angular/cdk": "^5.2.5", "@angular/common": "5.2.7", "@angular/compiler": "5.2.7", "@angular/core": "5.2.7", "@angular/forms": "5.2.7", "@angular/http": "5.2.7", "@angular/material": "^5.2.5", "@angular/platform-browser": "5.2.7", "@angular/platform-browser

2022-03-26 08:33:45    分类:问答    angular   typescript   rxjs   rxjs5   rxjs6

How to get "Observable.of([]);" to work?

What is the correct expression and import for Observable.of([]);. import { of } from 'rxjs'; does not work for me.

2022-03-26 06:37:32    分类:问答    angular   typescript   rxjs   rxjs5   rxjs6

RXJS/Angular Prevent multiple HTTP on multiple subscribers

I have "mainData" service, it consists of 3 parts: currentPage used by paginator component to switch page. Can be updated at any point. folders contains all folders in the current folder. There are 2 components that use this observable (Types of listing of folder content) files contains all files in the current folder. There are 3 components that use this observable (Types of listing of folder content) The default view is the one without folders, thus I would like not to make unnecessary HTTP calls. public currentPage = new ReplaySubject(1); public folders: Observable<FLFolder[]>; public files

2022-03-23 05:05:11    分类:问答    angular   typescript   rxjs   rxjs6

Order of execution with rxjs asapscheduler

Considering I have the following code: let Rx = window['rxjs']; const { of, queueScheduler, asapScheduler, asyncScheduler, animationFrameScheduler } = Rx; const { observeOn, tap } = Rx.operators; console.clear(); let source$ = of(1, 2, 3, asapScheduler).pipe( tap((v) => { console.log('tap ', v); }), ) source$.subscribe((v) => { console.log('Value ', v); Promise.resolve().then(() => { console.log('Microtask value ', v); }); }); <script src="https://cdnjs.cloudflare.com/ajax/libs/rxjs/6.2.1/rxjs.umd.js"></script> Which I use asapScheduler operator. As per the documentation, asap will wait for

2022-03-19 21:56:47    分类:问答    rxjs   rxjs6   rxjs-observables   rxjs-pipeable-operators   rxjs-marbles

Angular template binding with Observable async pipe issue [duplicate]

This question already has an answer here: Template binding with function return Observable and async pipe (1 answer) Closed 1 year ago. Note I have created a simplified version of this question at Template binding with function return Observable and async pipe Template: <div *ngIf="entity?.ext.insuredDetails.insuredType$() | async as insuredType"> {{insuredType}} </div> insuredType$ definition: @NeedsElement(sp(115621),ap(116215)) insuredType$(): Observable<string> { return empty(); } NeedsElement decorator: export function NeedsElement(...mappings: NeedsElementMapping[]) { if (mappings.length

2022-03-17 10:14:53    分类:问答    angular   rxjs   rxjs6   rxjs-observables

Subject Subscription is triggered twice when I call .next() once in Angular app

i'm trying to create a reusable Modal component. in a ModalService i have a Subject, and a method that that calls next() on the subject. The ModalComponent subscribes to that subject, but whenever the method in the service is being called, the next function of the observer gets triggers twice. Anyone know what causes this? export class ModalService { openModal = new Subject(); constructor() { } open(cmp) { this.openModal.next(cmp); } } Modal Component: export class ModalComponent implements OnInit { component: ComponentRef<any>; @ViewChild('entry', { read: ViewContainerRef }) entry

2022-03-15 17:41:32    分类:问答    javascript   angular   rxjs   rxjs6   subject

I dont get rxjs 6 with angular 6 with interval, switchMap, and map

I want to update my rxjs code to 6 got I don't get it. Before I had the below that wouth poll for new data every 5 seconds: import { Observable, interval } from 'rxjs'; import { switchMap, map } from 'rxjs/operators'; var result = interval(5000).switchMap(() => this._authHttp.get(url)).map(res => res.json().results); Now...of course, it's broken and the documentation leaves me nowhere to go. How do I write the above to conform to rxjs 6? Thanks

2022-03-08 07:21:56    分类:问答    angular   rxjs   rxjs6