Currently I have two observables. One returns a list of clients and the other is fired when text changes.
I would like to emit the full result of clients and then switch over to the inner observable once the user has started filtering.
I'm also trying to achieve a debounce on the text being typed.
I've put together something that doesn't work to try and explain. As it currently is it only displays clients once I start typing text.
let obs = Observable.fromPromise(this.clientService.getClients())
.map((clients) => {
return clients.map((c) => new Client().fromObject(c));
});
this.clients = obs.switchMap((values) => {
return this.searchText.valueChanges
.debounceTime(400)
.distinctUntilChanged()
.map((text) => {
return values.filter((c) => c.isMatch(text));
});
});