Reactive-Extensions / RxJS

The Reactive Extensions for JavaScript
http://reactivex.io
Other
19.48k stars 2.1k forks source link

What kind of operator to use? #1495

Open Jscott388 opened 7 years ago

Jscott388 commented 7 years ago
var list = new Promise(function (resolve, reject) {
  rets.getAutoLogoutClient(config.clientSettings, (client) => {
    var results = client.search.query(SearchType, Class, Query, {
      limit: 1,
      offset: 1
    });
    resolve(results);
  });
});

var source = Rx.Observable.fromPromise(list);

source.subscribe(results => console.log(results.count));

This is real estate data. I am limited to certain amount of data I can return in one query. I need to cap my limit, say 500. If there are 1600 records, this would need to run 4 times. What operator would I use for this? So my first run would be limit 500, offset, 1... Then I each run I would need to do offset += limit until I my offset is > than the count.

Would I want to use the Observable.while? Not sure on how to work with this.

My results.count comes from this. Not showing all the data, but results.results[0] would give me over 520 fields of data that I have to parse through.

maxRowsExceeded: true, replyCode: '0', replyTag: 'OPERATION_SUCCESSFUL', replyText: 'SUCCESS', count: 1694, rowsReceived: 1,

paulpdaniels commented 7 years ago

This is more of a StackOverflow question, you'll get much more visibility there. But since you are here, I would suggest that you look at the expand operator, with the idea of recursively calling your API, until the total items returned equals the total count.

Jscott388 commented 7 years ago

@paulpdaniels Yeah I thought so, but I can't get my head around this as there isn't many examples of this any where that I can understand.

My problem is I have to run the call to even find the count. So I don't know where to start or where my .expand will be placed into.

paulpdaniels commented 7 years ago

Just saw your post, I'll see if I can put together an answer. And again apologies for not elaborating more on here, but SO has a lot more visibility, and it is likely if you are having an issue then so are others, and I would hate for any answer to get buried in an old issue thread.

larssn commented 7 years ago

Yeah IMO post on SO, as the answer might bring value to others. 👍