Pārlūkot izejas kodu

EventSubscription interface

Daniel Zlotin 7 gadus atpakaļ
vecāks
revīzija
88b200b165

+ 9
- 5
lib/src/adapters/NativeEventsReceiver.ts Parādīt failu

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
 export class NativeEventsReceiver {
7
 export class NativeEventsReceiver {
4
   private emitter: NativeEventEmitter;
8
   private emitter: NativeEventEmitter;
6
     this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
10
     this.emitter = new NativeEventEmitter(NativeModules.RNNEventEmitter);
7
   }
11
   }
8
 
12
 
9
-  registerAppLaunched(callback): EmitterSubscription {
13
+  registerAppLaunched(callback): EventSubscription {
10
     return this.emitter.addListener('RNN.appLaunched', callback);
14
     return this.emitter.addListener('RNN.appLaunched', callback);
11
   }
15
   }
12
 
16
 
13
-  registerComponentDidAppear(callback): EmitterSubscription {
17
+  registerComponentDidAppear(callback): EventSubscription {
14
     return this.emitter.addListener('RNN.componentDidAppear', callback);
18
     return this.emitter.addListener('RNN.componentDidAppear', callback);
15
   }
19
   }
16
 
20
 
17
-  registerComponentDidDisappear(callback): EmitterSubscription {
21
+  registerComponentDidDisappear(callback): EventSubscription {
18
     return this.emitter.addListener('RNN.componentDidDisappear', callback);
22
     return this.emitter.addListener('RNN.componentDidDisappear', callback);
19
   }
23
   }
20
 
24
 
21
-  registerInteraction(callback): EmitterSubscription {
25
+  registerInteraction(callback): EventSubscription {
22
     return this.emitter.addListener('RNN.interaction', callback);
26
     return this.emitter.addListener('RNN.interaction', callback);
23
   }
27
   }
24
 }
28
 }

+ 4
- 4
lib/src/commands/OptionsProcessor.ts Parādīt failu

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

+ 1
- 1
lib/src/events/EventsRegistry.ts Parādīt failu

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

+ 1
- 1
playground/src/app.js Parādīt failu

22
 
22
 
23
 function start() {
23
 function start() {
24
   registerScreens();
24
   registerScreens();
25
-  Navigation.events().onAppLaunched(() => {
25
+  Navigation.events().appLaunched(() => {
26
     Navigation.setDefaultOptions({
26
     Navigation.setDefaultOptions({
27
       _animations: {
27
       _animations: {
28
         push: {
28
         push: {