Skip to content

Commit

Permalink
Update rxjs package
Browse files Browse the repository at this point in the history
  • Loading branch information
dmacfarlane committed Jan 6, 2024
1 parent a9e01ce commit f766076
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 181 deletions.
195 changes: 28 additions & 167 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"angular-in-memory-web-api": "^0.17.0",
"codelyzer": "^6.0.2",
"core-js": "^3.35.0",
"rxjs": "~6.5.5",
"rxjs-compat": "^6.5.5",
"rxjs": "^7.8.1",
"tinymce": "^6.8.2",
"tslib": "^2.4.0",
"zone.js": "~0.14.2"
Expand Down
19 changes: 7 additions & 12 deletions projects/demo-app/src/app/demo-async/demo-async.component.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';

import { Observable } from 'rxjs/Observable';
import { Subject } from 'rxjs/Subject';

import 'rxjs/add/operator/debounceTime';
import 'rxjs/add/operator/distinctUntilChanged';
import 'rxjs/add/observable/of';
import 'rxjs/add/operator/switchMap';
import { Observable, Subject, debounceTime, distinctUntilChanged, of, switchMap } from 'rxjs';

@Component({
selector: 'app-demo-async',
Expand All @@ -17,10 +11,11 @@ export class DemoAsyncComponent implements OnInit {
httpItems: Observable<any[]>;
private searchTermStream = new Subject();
ngOnInit() {
this.httpItems = this.searchTermStream
.debounceTime(500)
.distinctUntilChanged()
.switchMap((term: string) => this.getItems(term));
this.httpItems = this.searchTermStream.pipe(
debounceTime(500),
distinctUntilChanged(),
switchMap((term: string) => this.getItems(term))
);
}
search(term: string) {
this.searchTermStream.next(term);
Expand All @@ -32,7 +27,7 @@ export class DemoAsyncComponent implements OnInit {
console.log('getItems:', term);
if (!term) {
// if the search term is empty, return an empty array
return Observable.of([]);
return of([]);
}
// return this.http.get('api/names') // get all names
return this.http.get<any[]>('api/objects?label='+term); // get filtered names
Expand Down

0 comments on commit f766076

Please sign in to comment.