Kaynağa Gözat

EventSubscription interface

Daniel Zlotin 6 yıl önce
ebeveyn
işleme
88b200b165

+ 9
- 5
lib/src/adapters/NativeEventsReceiver.ts Dosyayı Görüntüle

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

+ 4
- 4
lib/src/commands/OptionsProcessor.ts Dosyayı Görüntüle

@@ -9,8 +9,8 @@ export class OptionsProcessor {
9 9
     _.forEach(options, (value, key) => {
10 10
       if (!value) { return; }
11 11
 
12
-      this.processColors(key, value, options);
13
-      this.processImages(key, value, options);
12
+      this.processColor(key, value, options);
13
+      this.processImage(key, value, options);
14 14
       this.processButtonsPassProps(key, value);
15 15
 
16 16
       if (_.isObject(value) || _.isArray(value)) {
@@ -19,13 +19,13 @@ export class OptionsProcessor {
19 19
     });
20 20
   }
21 21
 
22
-  private processColors(key, value, options) {
22
+  private processColor(key, value, options) {
23 23
     if (_.isEqual(key, 'color') || _.endsWith(key, 'Color')) {
24 24
       options[key] = processColor(value);
25 25
     }
26 26
   }
27 27
 
28
-  private processImages(key, value, options) {
28
+  private processImage(key, value, options) {
29 29
     if (_.isEqual(key, 'icon') || _.isEqual(key, 'image') || _.endsWith(key, 'Icon') || _.endsWith(key, 'Image')) {
30 30
       options[key] = resolveAssetSource(value);
31 31
     }

+ 1
- 1
lib/src/events/EventsRegistry.ts Dosyayı Görüntüle

@@ -1,4 +1,4 @@
1
-import { EventSubscription } from 'react-native';
1
+import { EventSubscription } from '../adapters/NativeEventsReceiver';
2 2
 
3 3
 export class EventsRegistry {
4 4
   private nativeEventsReceiver;

+ 1
- 1
playground/src/app.js Dosyayı Görüntüle

@@ -22,7 +22,7 @@ if (Platform.OS === 'android') {
22 22
 
23 23
 function start() {
24 24
   registerScreens();
25
-  Navigation.events().onAppLaunched(() => {
25
+  Navigation.events().appLaunched(() => {
26 26
     Navigation.setDefaultOptions({
27 27
       _animations: {
28 28
         push: {