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 componentDidAppear = @"RNN.componentDidAppear";
  6. static NSString* const componentDidDisappear = @"RNN.componentDidDisappear";
  7. static NSString* const onNavigationButtonPressed = @"RNN.navigationButtonPressed";
  8. -(NSArray<NSString *> *)supportedEvents {
  9. return @[onAppLaunched, componentDidAppear, componentDidDisappear, onNavigationButtonPressed];
  10. }
  11. # pragma mark public
  12. -(void)sendOnAppLaunched {
  13. [self send:onAppLaunched body:nil];
  14. }
  15. -(void)sendComponentDidAppear:(NSString *)componentId {
  16. [self send:componentDidAppear body:componentId];
  17. }
  18. -(void)sendComponentDidDisappear:(NSString *)componentId {
  19. [self send:componentDidDisappear body:componentId];
  20. }
  21. -(void)sendOnNavigationButtonPressed:(NSString *)componentId buttonId:(NSString*)buttonId {
  22. [self send:onNavigationButtonPressed body:@{@"componentId":componentId , @"buttonId": buttonId }];
  23. }
  24. # pragma mark private
  25. -(void)send:(NSString *)eventName body:(id)body {
  26. [self sendEventWithName:eventName body:body];
  27. }
  28. @end