Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still hard to figure out how to send events #19

Open
lucaswitch opened this issue Nov 13, 2024 · 2 comments
Open

Still hard to figure out how to send events #19

lucaswitch opened this issue Nov 13, 2024 · 2 comments

Comments

@lucaswitch
Copy link

https://github.com/react-native-community/RNNewArchitectureLibraries/tree/feat/swift-event-emitter
When trying to implement the new event emitter pattern.
Can we still rely on RCTEventEmitter on new arch or that is something that will be removed?

@cipolleschi
Copy link
Collaborator

These examples are quite outdated(React Native 0.71)
We have better examples in the new documentation: ios, with events

We will add more guides in the future. For the swift support, is should not be much different though: you still need a wrapper in objective-C++ that extends the module and the wrapper needs to be composed with the swift implementation. You can pass to swift a delegate with the wrapper and call the emit from there. RCTEventEmitter is the old architecture way to emit events, now that we have type-safe event emitters generated by codegen.

@lucaswitch
Copy link
Author

These examples are quite outdated(React Native 0.71) We have better examples in the new documentation: ios, with events

We will add more guides in the future. For the swift support, is should not be much different though: you still need a wrapper in objective-C++ that extends the module and the wrapper needs to be composed with the swift implementation. You can pass to swift a delegate with the wrapper and call the emit from there. RCTEventEmitter is the old architecture way to emit events, now that we have type-safe event emitters generated by codegen.

Thank you for the amazing work!

I guess many libraries prefer to use swift over objective c++.
We're not quite sure how to use objective c++ swift wrapper on new arch.
Can you provide an example with that configuration?

On bridge docs we're adding that feature like this:

Objective C

@interface RCT_EXTERN_MODULE(SomeAwesomeLibraryInObjC, NSObject)
// the methods
@end

Swift

@objc(SomeAwesomeLibraryInObjC)
class SomeAwesomeLibrary

But i'm sure that will not work on new arch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants