Skip to content

Implement Observable.spawn(function* (){}) #1497

@sladiri

Description

@sladiri

It seems that the spawn function is not implemented in RxJS5. As such, I cannot yield to Observables.
Our use case is to retrieve paginated data from a web-server. This is my how I can do it in RxJS4:

Rx.Observable.spawn(function* () {
  const limit = 2;
  try {
    const aprxjs = Rx.Observable.fromCallback(api);
    const lazyArr = [];
    yield aprxjs(0)
      .expand(v => v < limit ? aprxjs(v) : Rx.Observable.empty())
      .do(v => lazyArr.push(v));
  }
  catch (e) { console.log('er', e.stack); }
}).subscribe();

Metadata

Metadata

Assignees

No one assigned

    Labels

    featurePRs and issues for features

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions