-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor Event to encourage and ease migration to `RCTModernEventEmit…
…ter` support Summary: The `Event` interface has been improved such that: 1. `getEventData` is now a default method on Event that returns null 2. `dispatch` has a default implementation that relies on getEventName() and getEventData() 3. `dispatchModern` can detect if surfaceId and event data are present; if not, it falls back to dispatch This will dramatically ease future migrations: at some point in the (distant) future, we can simply delete RCTEventEmitter and all use-cases will be supported by the current `Event` class without needing to introduce a 3rd transitional interface; and 99% of all Event classes can be simplified, delet their `dispatch` implementation and need no further work. At their core, all Events are simply: (1) a name, (2) data, (3) a target (surfaceId and tag). The interface now reflects that but still allows for flexibility of the data and names being generated on-demand if necessary; but for the vast majority of Event classes, code will be dramatically simplified. I also migrate a single Event class, ContentSizeChangeEvent, to use this new method of dispatch. Changelog: [Android][Changed] Added convenience methods to simplify native Event classes and ease migrations Reviewed By: mdvacca Differential Revision: D26043325 fbshipit-source-id: bc308105f7f6e654d45fd156dbf4a2bcbc45819c
- Loading branch information
1 parent
de8aa2c
commit 72d0ddc
Showing
3 changed files
with
58 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters