You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my app, a user can create any number of tabs. Each tab needs to listen to an event for when the user switches to it. As I see it this can be done in two different ways:
// emitter.ts// Use symbol for static event namesexportconstsomeOtherEvent=Symbol()typeEvents={[someOtherEvent]: string,// Use string for dynamic event names[name: string]: any,}exportconstemitter=mitt<Events>()
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Are dynamic event names a good idea?
In my app, a user can create any number of tabs. Each tab needs to listen to an event for when the user switches to it. As I see it this can be done in two different ways:
Static event name:
Pros:
Cons:
Dynamic event name:
Pros:
Cons:
show-tab
eventsBeta Was this translation helpful? Give feedback.
All reactions