Replies: 2 comments 1 reply
-
I'm not sure I got your point here. How would you change the event definition? |
Beta Was this translation helpful? Give feedback.
1 reply
-
This may get into more advanced typescript that I'm less familiar without experimenting. Thinking from a consumer and exploring to maybe spark better ideas... I don't like this but this would work: new NativeEventEmitter<
GenericEventEmitter<'InitializeSucceeded'> &
GenericEventEmitter<'InitializeFailed', NativeFooBarInitializeFailedEvent> &
GenericEventEmitter<'AuthExpired'> &
GenericEventEmitter<'UserLeft'> &
GenericEventEmitter<'UserJoin'>
>(nativeModule) A little weird too but could also work... type FooBarEvents = {
'InitializeSucceeded': undefined,
'InitializeFailed': NativeFooBarInitializeFailedEvent
}
new NativeEventEmitter<FooBarEvents>(nativeModule) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I like where this is going: https://reactnative.dev/docs/next/new-architecture-library-intro#turbomodules-define-specs-in-javascript as it is aligning with how I'm creating the RN modules. I would like to point out that if using typescript or flow, I can see a very common consistency between iOS and android that we want to create specs for are the types for the event emitters, which includes event type and the event (context to help with terminology referenced here
addListener(eventType: string, listener: (event: any) => void, context?: Object): EmitterSubscription;
.Here is an example that we are doing right now. Not perfect and can be improved, but hopefully to get an idea.
Beta Was this translation helpful? Give feedback.
All reactions