Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for params and query object streams #50

Open
daffl opened this issue Apr 12, 2017 · 1 comment
Open

Add support for params and query object streams #50

daffl opened this issue Apr 12, 2017 · 1 comment

Comments

@daffl
Copy link
Member

daffl commented Apr 12, 2017

Basically, if one of the arguments (or the params.query) is an observable we should do what was suggested in #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 });
@daffl daffl changed the title Add support for query object strings Add support for params and query object streams Apr 12, 2017
@j2L4e
Copy link
Collaborator

j2L4e commented May 8, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants