question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Discussion] Custom Event Names

See original GitHub issue

Currently, 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:closed
  • Created 8 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
idecommented, Jun 19, 2015

These event types should be distributed among the modules that declare them.

Is this too complicated to do? Maybe I can take a shot at attempting this.

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.

So the point here is that any Native Module should be able to define events, not just the ones that inherit from RCTViewManager?

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.

This is the bit where I was suggesting why even specify event names. Why not just call the event and map it to corresponding event name in JS automatically. What are the challenges in doing so?

I’m not sure - you could read the code to learn that.

Also, what is the difference between customBubblingEventTypes and customDirectEventTypes?

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”.

0reactions
cosmithcommented, Sep 22, 2015

+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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found