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

What operators *require* a synchronous error or complete? #131

Closed
dead-claudia opened this issue Dec 29, 2016 · 4 comments
Closed

What operators *require* a synchronous error or complete? #131

dead-claudia opened this issue Dec 29, 2016 · 4 comments

Comments

@dead-claudia
Copy link

Besides onErrorResumeNext, what operators require a synchronous error or complete?

(Stemmed from @zenparsing's response to a quick strawman of mine.)

/cc @Blesh @jhusain

@dead-claudia
Copy link
Author

I'm aware that onErrorResumeNext likely requires internal help, anyways.

@acutmore
Copy link

'Require' is a tough criteria. From experience using RxJs's implementation of Observables in user interfaces which run on devices with limited resources, maximising synchronous calls is essential to achieving performance. An asynchronous call can't be inlined.

One example where an asynchronous complete would delay getting a value to an observer:

const lastValue = observable =>
  new Observable(observer => {
    const cache = [];
    return observable.subscribe(
      value => cache[0] = value,
      err => observer.error(err),
      () => {
          if (cache.length === 1) {
              observer.next(cache[0]);     
          }
          observer.complete();
      }
    );
 });

@jhusain
Copy link
Collaborator

jhusain commented Dec 31, 2016

Observables must be able to synchronously dispatch complete and error notifications. See here for a comprehensive explanation. https://docs.google.com/document/d/1Zo-ls61hNviKl-hfLSoR3NeGoIA-Z0cBvQRof5YEzVw

The rationale document above includes several operators which need the ability to dispatch synchronously.

@jhusain jhusain closed this as completed Dec 31, 2016
@dead-claudia
Copy link
Author

@jhusain Thanks!

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

No branches or pull requests

3 participants