@fto-consult/expo-ui 6.21.3 → 6.21.4

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.
Files changed (2) hide show
  1. package/index.js +10 -5
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,10 +1,13 @@
1
1
  import { registerRootComponent } from "expo";
2
+ import { View } from "react-native";
2
3
  import App from "./src/App";
3
4
  import Provider from "$econtext/Provider";
4
- import APP from "$capp/instance";
5
5
  const REGISTER_EVENT = "REGISTER-APP-COMPONENT-ROOT";
6
6
  import {useState,useEffect} from "react";
7
7
  const appRegisteredRef = {current:false};
8
+ import {observable} from "$clib/observable";
9
+ const context = {};
10
+ observable(context);
8
11
 
9
12
  /****
10
13
  * les options sont de la forme :
@@ -26,19 +29,21 @@ const appRegisteredRef = {current:false};
26
29
  const MainAppEntry = function(mProps){
27
30
  const [props,setProps] = useState(null);
28
31
  const onRegisterProps = (props)=>{
32
+ if(appRegisteredRef.current) return;
29
33
  appRegisteredRef.current = true;
30
34
  console.log(props," is registered");
31
35
  setProps({...props});
32
36
  }
33
37
  useEffect(()=>{
34
- APP.on(REGISTER_EVENT,onRegisterProps);
38
+ console.log("binding event ",context);
39
+ context.on(REGISTER_EVENT,onRegisterProps);
35
40
  return ()=>{
36
- APP.off(REGISTER_EVENT,onRegisterProps);
41
+ context.off(REGISTER_EVENT,onRegisterProps);
37
42
  }
38
43
  },[]);
39
44
  if(!props) {
40
45
  console.log(props," not registered",mProps);
41
- return null;
46
+ return <View/>;
42
47
  }
43
48
  const rProps = {...mProps,...props};
44
49
  console.log(rProps," is props ready to render");
@@ -49,7 +54,7 @@ const MainAppEntry = function(mProps){
49
54
  export default function registerApp (opts){
50
55
  if(appRegisteredRef.current) return false;
51
56
  console.log("will register event ",opts);
52
- return APP.trigger(REGISTER_EVENT,opts);
57
+ return context.trigger(REGISTER_EVENT,opts);
53
58
  }
54
59
 
55
60
  registerRootComponent(MainAppEntry);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "6.21.3",
3
+ "version": "6.21.4",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {