react-native-navigation的迁移库

RNNEventEmitter.m 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #import "RNNEventEmitter.h"
  2. @implementation RNNEventEmitter
  3. RCT_EXPORT_MODULE();
  4. static NSString* const onAppLaunched = @"RNN.appLaunched";
  5. static NSString* const containerDidAppear = @"RNN.containerDidAppear";
  6. static NSString* const containerDidDisappear = @"RNN.containerDidDisappear";
  7. static NSString* const onNavigationButtonPressed = @"RNN.navigationButtonPressed";
  8. -(NSArray<NSString *> *)supportedEvents {
  9. return @[onAppLaunched, containerDidAppear, containerDidDisappear, onNavigationButtonPressed];
  10. }
  11. # pragma mark public
  12. -(void)sendOnAppLaunched {
  13. [self send:onAppLaunched body:nil];
  14. }
  15. -(void)sendContainerDidAppear:(NSString *)containerId {
  16. [self send:containerDidAppear body:containerId];
  17. }
  18. -(void)sendContainerDidDisappear:(NSString *)containerId {
  19. [self send:containerDidDisappear body:containerId];
  20. }
  21. -(void)sendOnNavigationButtonPressed:(NSString *)containerId buttonId:(NSString*)buttonId {
  22. [self send:onNavigationButtonPressed body:@{@"containerId":containerId , @"buttonId": buttonId }];
  23. }
  24. # pragma mark private
  25. -(void)send:(NSString *)eventName body:(id)body {
  26. [self sendEventWithName:eventName body:body];
  27. }
  28. @end