Skip to content

fix(EventEmitter): resolve onError and onComplete asynchronously#4825

Closed
NathanWalker wants to merge 1 commit into
angular:masterfrom
NathanWalker:eventemitter-settimeout
Closed

fix(EventEmitter): resolve onError and onComplete asynchronously#4825
NathanWalker wants to merge 1 commit into
angular:masterfrom
NathanWalker:eventemitter-settimeout

Conversation

@NathanWalker
Copy link
Copy Markdown
Contributor

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch 3 times, most recently from 9cba06d to 6c87180 Compare October 29, 2015 20:08
@robwormald
Copy link
Copy Markdown
Contributor

@NathanWalker watch for #4893 as it will definitely impact this. the (annoyingly ugly) change will be that EventEmitter.subscribe() takes either .subscribe(nextFn, errorFn, completeFn) or .subscribe(observerObj) where observerObj is { next(), error(), complete() }

@NathanWalker
Copy link
Copy Markdown
Contributor Author

@robwormald thanks for heads up 👍

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from 6c87180 to 59286f3 Compare October 30, 2015 03:00
@robwormald
Copy link
Copy Markdown
Contributor

while you're at it, i just found a nasty little hiccup, maybe have a look as you're in the guts of this right now:

//create a subject
var s = new Subject();

//subscribe to it via the ObservableWrapper, passing only a next fn
ObservableWrapper.subscribe(s, (val) => {});

//call next
s.next(1);
//call complete (throws!)
s.complete();

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch 2 times, most recently from 0320930 to 1170337 Compare October 30, 2015 03:58
@NathanWalker
Copy link
Copy Markdown
Contributor Author

This should solve your issue above as well @robwormald. Have a look and let me know.

/cc @vsavkin

@NathanWalker
Copy link
Copy Markdown
Contributor Author

As far as I can tell, async.ts does not have any unit tests. I could add some for this unless I'm missing something?

@robwormald
Copy link
Copy Markdown
Contributor

specs are here https://github.com/angular/angular/blob/master/modules/angular2/test/core/facade/async_spec.ts

I have one locally that looks like that throws - this replicates what I mentioned above.

it('should subscribe to Subjects', () => {
  let subject = new Subject();

  ObservableWrapper.subscribe(subject, (val) => {});

  subject.next(1);
  subject.complete();

})

@NathanWalker
Copy link
Copy Markdown
Contributor Author

Ah ok. Lemme try that on my branch here.

@NathanWalker
Copy link
Copy Markdown
Contributor Author

I have a fix coming (verified in isolation). Running locally all build/tests and will push the squashed commit shortly.

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from 1170337 to f57cfc6 Compare October 30, 2015 18:51
@NathanWalker
Copy link
Copy Markdown
Contributor Author

I used the same approach the RxJS team did here:
https://github.com/ReactiveX/RxJS/blob/master/src/Subscriber.ts#L38

Also the unit test now includes yours with an expansion to verify different signatures would still work.

I'm just now seeing your comment... lemme see...

@robwormald
Copy link
Copy Markdown
Contributor

otherwise tho, LGTM

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from f57cfc6 to e74d975 Compare October 30, 2015 18:59
@NathanWalker
Copy link
Copy Markdown
Contributor Author

Good point. I updated the unit tests so it didn't look confusing. Not sure if there's anything we should do to prevent .complete from firing if .error had been called? Probably best to rely on RxJS's underlying implementation for that? Thanks for the help and feedback 👍

@robwormald
Copy link
Copy Markdown
Contributor

Hmm, dart not loving that (the TS specs get xpiled to dart and executed as well) - might try calling using the wrapper there:

ObservableWrapper.callNext(e, 1);

etc

@NathanWalker
Copy link
Copy Markdown
Contributor Author

Thanks I'll try that shortly.

On Fri, Oct 30, 2015 at 12:17 PM Rob Wormald notifications@github.com
wrote:

Hmm, dart not loving that (the TS specs get xpiled to dart and executed as
well) - might try calling using the wrapper there:

ObservableWrapper.callNext(e, 1);

etc


Reply to this email directly or view it on GitHub
#4825 (comment).

@jeffbcross
Copy link
Copy Markdown
Contributor

@NathanWalker can you add "closes #4443" in your commit message?

Also, could you shorten the title to "fix(EventEmitter): resolve onError and onComplete asynchronously"

This should also be noted as a breaking change, so a BREAKING CHANGE: section should be added to the body, explaining the previous behavior and new behavior.

@jeffbcross
Copy link
Copy Markdown
Contributor

Meh, nm about breaking change.

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from e74d975 to df34840 Compare October 30, 2015 21:01
@NathanWalker
Copy link
Copy Markdown
Contributor Author

Thanks @jeffbcross @robwormald that should clear things up 👍

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from df34840 to 0a2301b Compare October 31, 2015 03:04
@NathanWalker NathanWalker changed the title fix(EventEmitter): resolve onError and onComplete asynchronously for both onError and onComplete fix(EventEmitter): resolve onError and onComplete asynchronously Oct 31, 2015
@vsavkin vsavkin removed their assignment Nov 2, 2015
@naomiblack naomiblack modified the milestone: beta-00 Nov 2, 2015
@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch 2 times, most recently from fcb7eb3 to 877858c Compare November 17, 2015 22:48
@NathanWalker
Copy link
Copy Markdown
Contributor Author

I added unit tests for async onError and onComplete and have everything passing now.
Should be clear now @robwormald

@robwormald
Copy link
Copy Markdown
Contributor

@NathanWalker awesome. once #5302 lands, rebase and we should be good to go.

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from 877858c to ae79fb1 Compare November 19, 2015 02:47
@NathanWalker
Copy link
Copy Markdown
Contributor Author

5302 came, it saw, and landed; then this just dropped the rebass! take it away @robwormald :shipit:

@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from ae79fb1 to 7a0068a Compare November 20, 2015 19:23
@NathanWalker NathanWalker force-pushed the eventemitter-settimeout branch from 7a0068a to ae5e8ec Compare November 21, 2015 07:15
@robwormald
Copy link
Copy Markdown
Contributor

LGTM. failing test is dartdoc known issue.

@robwormald robwormald added pr_state: LGTM action: merge The PR is ready for merge by the caretaker labels Nov 21, 2015
@vsavkin
Copy link
Copy Markdown
Contributor

vsavkin commented Nov 25, 2015

Merged via 019cb41

@vsavkin vsavkin closed this Nov 25, 2015
@NathanWalker NathanWalker deleted the eventemitter-settimeout branch December 1, 2015 04:51
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker cla: yes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants