feathers-reactive
feathers-reactive copied to clipboard
Add support for params and query object streams
Basically, if one of the arguments (or the params.query) is an observable we should do what was suggested in https://github.com/feathersjs/feathers-reactive/issues/39 and mergeMap them into a single stream:
const service = app.service('messages');
const query = new RxJS.BehaviorSubject({ $skip: 0 });
const find = query.mergeMap(query => service.find({ query }));
find.subscribe(data => console.log('Data is', data));
query.next({ $skip: 10 });
You also need to choose if you want to switch or merge. e.g. classic pagination vs infinite scrolling. How about this:
find(params$, merge = false){
if(isObservable(params$)){
return merge
? params$.mergeMap(params => this.find(params))
: params$.switchMap(params => this.find(params));
} else {
return this._find(params$); // "normal" find
}
}
Edit: I think switching should be the default behavior.