Skip to content

Commit 46499d5

Browse files
authored
Merge pull request #448 from almothafar/master
RxJS 7 migration
2 parents bbf048f + 04c81ad commit 46499d5

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## [18.0.0] Major Update
22

33
- Upgraded to support Angular 18
4+
- Migration for deprecated Observable<T> params
45
- Adding e2e smock test for the project removing deprecated protractor adding cypress
56

67
## [17.0.0] Major Update

projects/auto-complete/src/lib/auto-complete.component.ts

+22-21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild, ViewEncapsulation } from '@angular/core';
22
import { NguiAutoCompleteService } from './auto-complete.service';
3+
import { Observable } from 'rxjs';
34

45
@Component({
56
selector: 'ngui-auto-complete',
@@ -132,39 +133,39 @@ export class NguiAutoCompleteComponent implements OnInit {
132133
this.filteredList = this.filteredList.slice(0, this.maxNumList);
133134
}
134135

135-
} else { // remote source
136+
} else {// remote source
136137
this.isLoading = true;
137138

138139
if (typeof this.source === 'function') {
139140
// custom function that returns observable
140-
this.source(keyword).subscribe(
141-
(resp) => {
142-
143-
if (this.pathToData) {
144-
const paths = this.pathToData.split('.');
145-
paths.forEach((prop) => resp = resp[prop]);
146-
}
147-
148-
this.filteredList = resp;
149-
if (this.maxNumList) {
150-
this.filteredList = this.filteredList.slice(0, this.maxNumList);
151-
}
152-
},
153-
(error) => console.warn(error),
154-
() => this.isLoading = false // complete
141+
(this.source(keyword) as Observable<any>).subscribe({
142+
next: (resp) => {
143+
if (this.pathToData) {
144+
const paths = this.pathToData.split('.');
145+
paths.forEach((prop) => resp = resp[prop]);
146+
}
147+
148+
this.filteredList = resp;
149+
if (this.maxNumList) {
150+
this.filteredList = this.filteredList.slice(0, this.maxNumList);
151+
}
152+
},
153+
error: (error) => console.warn(error),
154+
complete: () => this.isLoading = false
155+
}
155156
);
156157
} else {
157158
// remote source
158-
159-
this.autoComplete.getRemoteData(keyword).subscribe((resp) => {
159+
this.autoComplete.getRemoteData(keyword).subscribe({
160+
next: (resp) => {
160161
this.filteredList = resp ? resp : [];
161162
if (this.maxNumList) {
162163
this.filteredList = this.filteredList.slice(0, this.maxNumList);
163164
}
164165
},
165-
(error) => console.warn(error),
166-
() => this.isLoading = false // complete
167-
);
166+
error: (error) => console.warn(error),
167+
complete: () => this.isLoading = false
168+
});
168169
}
169170
}
170171
}

0 commit comments

Comments
 (0)