[Discussion] Custom Event Names
See original GitHub issueCurrently, there is no way for a custom native module to make custom event names like onVideoPlayerDidLoad
. There is only one global list of event names defined in RCTUIManager.m.
There is also a comment there regarding this, but I cannot find a corresponding issue, hence creating one and sharing my thoughts.
// TODO: these event types should be distributed among the modules
// that declare them. Also, events should be registrable by any class
// that can call event handlers, not just UIViewManagers. This code
// also seems highly redundant - every event has the same properties.
Instead of making the native module specify names for each and every event, what if the event name is generated automatically? So on calling [self.bridge.eventDispatcher sendInputEventWithName:@"onVideoPlayerDidLoad" body:event];
it will internally call onVideoPlayerDidLoad
on the JS and for capture phase: onVideoPlayerDidLoadCapture
.
Is there some reason we need to specify the mappings beforehand?
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (7 by maintainers)
Top Results From Across the Web
Solved: Custom event names in GA4 - Tealium Learning Center
Solved: Hi All, Do you know if there's a way to send custom GA4 events, for example: ... The "Custom Name" is the...
Read more >Custom event/metric naming syntax & hyphens - Dashboards
The documentation has this description of naming syntax: Naming syntax: Attribute names can be a combination of alphanumeric characters, colons ...
Read more >Standardizing of "Custom Event" Place Names
Note the different fields for "Event Place (Original)" and "Event Place" - the latter having the appearance of a perfectly acceptable standard ...
Read more >Custom Events - Braze
Custom events are actions taken by, or updates about, your users. They're best suited for tracking high-value user interactions within your application.
Read more >Custom events - HARMAN Professional Forums
The Custom Event is one of those names that I feel doesn't accurately describe its function but I also don't have a better...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Probably would be appreciated. Some of the events might be shared by multiple modules though, so centralizing them in the UIManager might make sense. Also Facebook may have internal modules that also use the same events so you’d need to get someone to test the FB apps too.
I guess so but it doesn’t seem that useful because all modules can already emit events via the NativeAppEventEmitter and DeviceEventEmitter. The limitation now is just that non-view managers cannot fire UI events… which seems mostly fine. If someone has a compelling use case then we could look into it.
I’m not sure - you could read the code to learn that.
Bubbling events are like DOM events so that a parent component can capture an event fired by its child. Generally these are UI-related, like “the user touched this box”. Direct events are not bubbled and are intended for more abstract events like “this image failed to load”.
+1 for the docs, spent a long time before realizing that I had to implement
- (NSArray*)customBubblingEventTypes
in my manager to declare my event names. I might submit a PR later.