|
@@ -11,9 +11,10 @@ import _ from 'lodash';
|
11
|
11
|
const _allNavigatorEventHandlers = {};
|
12
|
12
|
|
13
|
13
|
class Navigator {
|
14
|
|
- constructor(navigatorID, navigatorEventID) {
|
|
14
|
+ constructor(navigatorID, navigatorEventID, screenInstanceId) {
|
15
|
15
|
this.navigatorID = navigatorID;
|
16
|
16
|
this.navigatorEventID = navigatorEventID;
|
|
17
|
+ this.screenInstanceId = screenInstanceId;
|
17
|
18
|
this.navigatorEventHandler = null;
|
18
|
19
|
this.navigatorEventSubscription = null;
|
19
|
20
|
}
|
|
@@ -101,9 +102,15 @@ class Navigator {
|
101
|
102
|
setOnNavigatorEvent(callback) {
|
102
|
103
|
this.navigatorEventHandler = callback;
|
103
|
104
|
if (!this.navigatorEventSubscription) {
|
104
|
|
- let Emitter = Platform.OS === 'android' ? DeviceEventEmitter : NativeAppEventEmitter;
|
105
|
|
- this.navigatorEventSubscription = Emitter.addListener(this.navigatorEventID, (event) => this.onNavigatorEvent(event));
|
106
|
|
- _allNavigatorEventHandlers[this.navigatorEventID] = (event) => this.onNavigatorEvent(event);
|
|
105
|
+ if (Platform.OS === 'android') {
|
|
106
|
+ let Emitter = DeviceEventEmitter;
|
|
107
|
+ this.navigatorEventSubscription = Emitter.addListener(this.screenInstanceId, (event) => this.onNavigatorEvent(event));
|
|
108
|
+ _allNavigatorEventHandlers[this.screenInstanceId] = (event) => this.onNavigatorEvent(event);
|
|
109
|
+ } else {
|
|
110
|
+ let Emitter = NativeAppEventEmitter;
|
|
111
|
+ this.navigatorEventSubscription = Emitter.addListener(this.navigatorEventID, (event) => this.onNavigatorEvent(event));
|
|
112
|
+ _allNavigatorEventHandlers[this.navigatorEventID] = (event) => this.onNavigatorEvent(event);
|
|
113
|
+ }
|
107
|
114
|
}
|
108
|
115
|
}
|
109
|
116
|
|
|
@@ -142,7 +149,11 @@ export default class Screen extends Component {
|
142
|
149
|
if (!props.navigatorID) {
|
143
|
150
|
props.navigatorID = _.uniqueId('navigatorId');
|
144
|
151
|
}
|
145
|
|
- this.navigator = new Navigator(props.navigatorID, props.navigatorEventID);
|
|
152
|
+ // TODO: keep this shit?
|
|
153
|
+ if (!props.screenInstanceId) {
|
|
154
|
+ props.screenInstanceId = _.uniqueId('screenInstanceId');
|
|
155
|
+ }
|
|
156
|
+ this.navigator = new Navigator(props.navigatorID, props.navigatorEventID, props.screenInstanceId);
|
146
|
157
|
}
|
147
|
158
|
|
148
|
159
|
componentWillUnmount() {
|