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

fix(fromEvent): Support React Native and node-compatible event sources. #3821

Merged

Conversation

ajcrites
Copy link
Contributor

React Native implements a similar interface to Node.js event listeners -- specifically, its Event Emitters have addListener and removeListener methods. These are compatible with the Node interface, but they are not identical to the Node.js style since the addListener method returns a subscription rather than the event emitter itself, and the removeListener method returns nothing.

These return values are not actually used by fromEvent, so creating an Observable from an Event Emitter where addListener returns something different and removeListener returns nothing should still work to create a compatible Observable that emits with the corresponding events.

Closes #3809

React Native implements a similar interface to Node.js event listeners -- specifically, its Event Emitters have addListener and removeListener methods. These are compatible with the Node interface, but they are not identical to the Node.js *style* since the addListener method returns a subscription rather than the event emitter itself, and the removeListener method returns nothing.

These return values are not actually used by fromEvent, so creating an Observable from an Event Emitter where addListener returns something different and removeListener returns nothing should still work to create a compatible Observable that emits with the corresponding events.
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.747% when pulling d4efd6f on ajcrites:ajcrites/fromEvent-node-compatible into 3b290ea on ReactiveX:master.

Copy link
Collaborator

@cartant cartant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@benlesh benlesh merged commit 1969f18 into ReactiveX:master Jun 11, 2018
@benlesh
Copy link
Member

benlesh commented Jun 11, 2018

Thanks, @ajcrites!

@ajcrites ajcrites deleted the ajcrites/fromEvent-node-compatible branch June 12, 2018 01:45
@lock lock bot locked as resolved and limited conversation to collaborators Jul 12, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants