hybrid-navigation 2.18.0 → 2.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,11 +13,11 @@ export function withNavigation(moduleName) {
13
13
  navigator.moduleName = moduleName;
14
14
  }
15
15
  useEffect(() => {
16
- Navigation.signalFirstRenderComplete(navigator.sceneId);
16
+ Navigation.signalFirstRenderComplete(sceneId);
17
17
  return () => {
18
- navigator.unmount();
18
+ Navigator.unmount(sceneId);
19
19
  };
20
- }, [navigator]);
20
+ }, [sceneId]);
21
21
  const injected = {
22
22
  navigator,
23
23
  };
@@ -17,6 +17,7 @@ export declare class Navigator implements Navigator {
17
17
  sceneId: string;
18
18
  moduleName?: string | undefined;
19
19
  static of(sceneId: string): Navigator;
20
+ static unmount: (sceneId: string) => void;
20
21
  static find(moduleName: string): Promise<Navigator | undefined>;
21
22
  static current(): Promise<Navigator>;
22
23
  constructor(sceneId: string, moduleName?: string | undefined);
@@ -25,7 +26,6 @@ export declare class Navigator implements Navigator {
25
26
  setParams: (params: {
26
27
  [index: string]: any;
27
28
  }) => void;
28
- unmount: () => void;
29
29
  push: <T extends ResultType, P extends PropsType = {}>(moduleName: string, props?: P, options?: NavigationItem) => Promise<[number, T]>;
30
30
  pushLayout: <T extends ResultType>(layout: BuildInLayout | Layout) => Promise<[number, T]>;
31
31
  pop: () => Promise<boolean>;
package/lib/Navigator.js CHANGED
@@ -24,6 +24,10 @@ export class Navigator {
24
24
  }
25
25
  return navigator;
26
26
  }
27
+ static unmount = (sceneId) => {
28
+ store.removeNavigator(sceneId);
29
+ Navigation.unmount(sceneId);
30
+ };
27
31
  static async find(moduleName) {
28
32
  const sceneId = await Navigation.findSceneIdByModuleName(moduleName);
29
33
  if (sceneId) {
@@ -45,10 +49,6 @@ export class Navigator {
45
49
  setParams = (params) => {
46
50
  this.state.params = { ...this.state.params, ...params };
47
51
  };
48
- unmount = () => {
49
- store.removeNavigator(this.sceneId);
50
- Navigation.unmount(this.sceneId);
51
- };
52
52
  push = async (moduleName, props = {}, options = {}) => {
53
53
  const success = await Navigation.dispatch(this.sceneId, 'push', {
54
54
  moduleName,
@@ -1,6 +1,4 @@
1
1
  import Event from '../Event';
2
- import NavigationModule from '../NavigationModule';
3
- const { RESULT_CANCEL } = NavigationModule.getConstants();
4
2
  export default class ResultEventHandler {
5
3
  listenerRecords = {};
6
4
  constructor() { }
@@ -28,14 +26,9 @@ export default class ResultEventHandler {
28
26
  }
29
27
  }
30
28
  invalidateResultEventListener(sceneId) {
31
- const listeners = this.listenerRecords[sceneId];
32
- if (listeners) {
33
- // Object.values(listeners).forEach(listener => listener(RESULT_CANCEL, null))
34
- Object.values(listeners)
35
- .reduce((acc, next) => [...acc, ...next], [])
36
- .forEach(listener => listener(RESULT_CANCEL, null));
29
+ if (this.listenerRecords[sceneId]) {
30
+ delete this.listenerRecords[sceneId];
37
31
  }
38
- delete this.listenerRecords[sceneId];
39
32
  }
40
33
  waitResult(sceneId, requestCode) {
41
34
  return new Promise(resolve => {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hybrid-navigation",
3
3
  "description": "React Native Navigation that supports seamless navigation between Native and React.",
4
- "version": "2.18.0",
4
+ "version": "2.18.1",
5
5
  "main": "./lib/index.js",
6
6
  "typings": "./lib/index.d.ts",
7
7
  "react-native": "src/index",
@@ -27,11 +27,11 @@ export function withNavigation(moduleName: string) {
27
27
  }
28
28
 
29
29
  useEffect(() => {
30
- Navigation.signalFirstRenderComplete(navigator.sceneId)
30
+ Navigation.signalFirstRenderComplete(sceneId)
31
31
  return () => {
32
- navigator.unmount()
32
+ Navigator.unmount(sceneId)
33
33
  }
34
- }, [navigator])
34
+ }, [sceneId])
35
35
 
36
36
  const injected = {
37
37
  navigator,
package/src/Navigator.ts CHANGED
@@ -41,6 +41,11 @@ export class Navigator implements Navigator {
41
41
  return navigator
42
42
  }
43
43
 
44
+ static unmount = (sceneId: string) => {
45
+ store.removeNavigator(sceneId)
46
+ Navigation.unmount(sceneId)
47
+ }
48
+
44
49
  static async find(moduleName: string) {
45
50
  const sceneId = await Navigation.findSceneIdByModuleName(moduleName)
46
51
  if (sceneId) {
@@ -65,11 +70,6 @@ export class Navigator implements Navigator {
65
70
  this.state.params = { ...this.state.params, ...params }
66
71
  }
67
72
 
68
- unmount = () => {
69
- store.removeNavigator(this.sceneId)
70
- Navigation.unmount(this.sceneId)
71
- }
72
-
73
73
  push = async <T extends ResultType, P extends PropsType = {}>(
74
74
  moduleName: string,
75
75
  props: P = {} as P,
@@ -1,5 +1,5 @@
1
1
  import Event from '../Event'
2
- import NavigationModule from '../NavigationModule'
2
+
3
3
  interface IndexType {
4
4
  [index: string]: any
5
5
  }
@@ -7,7 +7,6 @@ interface IndexType {
7
7
  export type ResultType = IndexType | null
8
8
  export type ResultEventListener<T extends ResultType> = (resultCode: number, data: T) => void
9
9
 
10
- const { RESULT_CANCEL } = NavigationModule.getConstants()
11
10
  export default class ResultEventHandler {
12
11
  private listenerRecords: Record<string, Record<number, Array<ResultEventListener<any>>>> = {}
13
12
 
@@ -48,15 +47,9 @@ export default class ResultEventHandler {
48
47
  }
49
48
 
50
49
  invalidateResultEventListener(sceneId: string) {
51
- const listeners = this.listenerRecords[sceneId]
52
- if (listeners) {
53
- // Object.values(listeners).forEach(listener => listener(RESULT_CANCEL, null))
54
- Object.values(listeners)
55
- .reduce((acc, next) => [...acc, ...next], [])
56
- .forEach(listener => listener(RESULT_CANCEL, null))
50
+ if (this.listenerRecords[sceneId]) {
51
+ delete this.listenerRecords[sceneId]
57
52
  }
58
-
59
- delete this.listenerRecords[sceneId]
60
53
  }
61
54
 
62
55
  waitResult<T extends ResultType>(sceneId: string, requestCode: number): Promise<[number, T]> {