react-native-navigation的迁移库

NativeEventsReceiver.ts 822B

1234567891011121314151617181920212223242526272829
  1. import { NativeModules, NativeEventEmitter } from 'react-native';
  2. export interface EventSubscription {
  3. remove();
  4. }
  5. export class NativeEventsReceiver {
  6. private emitter: NativeEventEmitter;
  7. constructor() {
  8. this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
  9. }
  10. registerAppLaunched(callback): EventSubscription {
  11. return this.emitter.addListener('RNN.appLaunched', callback);
  12. }
  13. registerComponentDidAppear(callback): EventSubscription {
  14. return this.emitter.addListener('RNN.componentDidAppear', callback);
  15. }
  16. registerComponentDidDisappear(callback): EventSubscription {
  17. return this.emitter.addListener('RNN.componentDidDisappear', callback);
  18. }
  19. registerInteraction(callback): EventSubscription {
  20. return this.emitter.addListener('RNN.interaction', callback);
  21. }
  22. }