meteorrn / meteor-react-native

Meteor client for React Native matching Meteor Spec
https://guide.meteor.com/react-native.html
Other
59 stars 31 forks source link

Fix: use a maintained minimal event emitter to prevent missing events error #129

Closed jankapunkt closed 1 year ago

jankapunkt commented 1 year ago

Problem description

The release 2.5.0 contains an unintended issue, where events is implied as provider for EventEmitter.

However this was due to an assumption that RN simply bundles node's events as they don't contain any native bindings. However, this is not the case and the events that may have been used is actually a derivative from the npm registry:

https://www.npmjs.com/package/events

This is insufficient as it still requires an external dependency. Futhermore it raises errors on new installations: https://github.com/meteorrn/meteor-react-native/pull/116#issuecomment-1688830377

Solution

This PR attempts to solve this by using React Natives' NativeEventEmitter and wrapping it to contain the on and off functions to preserve the original API.

Tests

During test environment it falls back to events which is then supplied by Node, since we use Node to run the tests.

How to test in your setup?

You can simply install this via

$ npm install "git+ssh://git@github.com/meteorrn/meteor-react-native.git#fix-events"

and then build your app. Please make sure you have no events in your dependencies' ordevDependenciesor any other dependencies (optional, peer) inpackage.json`

Any issues reported are much appreciated!