react-globo-state 1.0.7 → 1.1.0

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.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # [React Globo State](https://npmjs.com/package/react-globo-state)
1
+ # [React Globo State - gState.](https://npmjs.com/package/react-globo-state)
2
2
 
3
3
  A react state everywhere, easy and smart ... Only one!
4
4
 
@@ -44,7 +44,13 @@ const App = () => {
44
44
  // init gState
45
45
  globoState()
46
46
 
47
- return <div>MyApp</div>
47
+ useEffect(
48
+ ()=>{
49
+ gState.set("test",{ myNewReactState: "hello world!" })
50
+ },[]
51
+ )
52
+
53
+ return <div>{ JSON.stringify(gState.get("test")) }</div>
48
54
 
49
55
  }
50
56
 
@@ -61,21 +67,21 @@ const App = () => {
61
67
  * Create a state
62
68
  * @param name - Name of the gstate
63
69
  * @param item - Object, string, number, boolean, array
64
- * @returns - Void
70
+ * @returns - true
65
71
  */
66
72
  gState.set("name", { test:"test" })
67
73
 
68
74
  /**
69
75
  * Get a state
70
76
  * @param name - Name of the gstate
71
- * @returns - Void
77
+ * @returns - items
72
78
  */
73
79
  gState.get("name")
74
80
 
75
81
  /**
76
82
  * Remove a state
77
83
  * @param name - Name of the gstate
78
- * @returns - Void
84
+ * @returns - items
79
85
  */
80
86
  gState.remove("name")
81
87
  // or
@@ -83,13 +89,13 @@ const App = () => {
83
89
 
84
90
  /**
85
91
  * Delete all items from gState
86
- * @returns - Void
92
+ * @returns - true
87
93
  */
88
94
  gState.deleteAll()
89
95
 
90
96
  /**
91
97
  * List all states
92
- * @returns - Void
98
+ * @returns - items
93
99
  */
94
100
  gState.list()
95
101
 
package/global.d.ts CHANGED
@@ -9,41 +9,47 @@ declare module 'globoState'
9
9
 
10
10
  interface _gState {
11
11
 
12
- init: () => void,
12
+ /**
13
+ * Dynamic index signature for additional properties
14
+ * @private
15
+ */
16
+ [key: string]: any
17
+
18
+
13
19
  /**
14
20
  * Create a state
15
21
  * @param name - Name of the gstate
16
22
  * @param item - Object, string, number, boolean, array
17
- * @returns - Void
23
+ * @returns - true
18
24
  */
19
- set: (name: string, value: string | number | string[] | object) => void,
25
+ set: (name: string, value: string | number | string[] | object) => true,
20
26
 
21
27
  /**
22
28
  * Get a state
23
29
  * @param name - Name of the gstate
24
- * @returns - Void
30
+ * @returns - value
25
31
  */
26
- get: (name: string) => void,
32
+ get: (name: string) => value,
27
33
 
28
34
  /**
29
35
  * Remove a state
30
36
  * @param name - Name of the gstate
31
- * @returns - Void
37
+ * @returns - true
32
38
  */
33
- remove: (name: string) => void,
34
- delete: (name: string) => void,
39
+ remove: (name: string) => true,
40
+ delete: (name: string) => true,
35
41
 
36
42
  /**
37
43
  * Delete all items from gState
38
44
  * @returns - Void
39
45
  */
40
- deleteAll: () => void,
46
+ deleteAll: () => true,
41
47
 
42
48
  /**
43
49
  * List all states
44
50
  * @returns - Void
45
51
  */
46
- list: () => void
52
+ list: () => values
47
53
  }
48
54
 
49
55
  declare var globoState: () => void
package/index.js CHANGED
@@ -1 +1 @@
1
- import{useState as g}from"react";const e={};globalThis.globoState=()=>{const[r,l]=g(null);globalThis.gState={get:t=>{if(t&&t)return r?.[t]?r[t]:null},set:(t,o)=>{!t||!o||(e[t]=o,l({...e}))},remove:t=>{t&&(delete e[t],l({...e}))},delete:t=>{t&&gState.remove(t)},deleteAll:()=>{l({})},list:()=>r}};
1
+ import{useState as n}from"react";const e={};globalThis.globoState=()=>{const[r,u]=n(null);globalThis.gState={get:t=>{if(t&&t)return r?.[t]?r[t]:null},set:(t,l)=>{if(!(!t||!l))return e[t]=l,u({...e}),!0},remove:t=>{if(t)return delete e[t],u({...e}),!0},delete:t=>{if(t)return gState.remove(t),!0},deleteAll:()=>(u({}),!0),list:()=>r}};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-globo-state",
3
- "version": "1.0.7",
3
+ "version": "1.1.0",
4
4
  "description": "A react state everywhere made easy",
5
5
  "keywords": [
6
6
  "react",