react-globo-state 1.0.6 → 1.0.7
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 +3 -3
- package/global.d.ts +4 -0
- package/index.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ A react state everywhere, easy and smart ... Only one!
|
|
|
14
14
|
|
|
15
15
|
## install
|
|
16
16
|
|
|
17
|
-
```
|
|
17
|
+
```bash
|
|
18
18
|
npm i -D react-globo-state
|
|
19
19
|
```
|
|
20
20
|
|
|
@@ -23,7 +23,7 @@ You use:
|
|
|
23
23
|
```javascript
|
|
24
24
|
|
|
25
25
|
// Import the init
|
|
26
|
-
import
|
|
26
|
+
import "react-globo-state"
|
|
27
27
|
|
|
28
28
|
// start the state
|
|
29
29
|
// * need to be inside your App() only at top and one time...
|
|
@@ -37,7 +37,7 @@ globoState()
|
|
|
37
37
|
## EXAMPLE
|
|
38
38
|
|
|
39
39
|
```js
|
|
40
|
-
import
|
|
40
|
+
import "react-globo-state"
|
|
41
41
|
|
|
42
42
|
const App = () => {
|
|
43
43
|
|
package/global.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ declare module 'gState'
|
|
|
8
8
|
declare module 'globoState'
|
|
9
9
|
|
|
10
10
|
interface _gState {
|
|
11
|
+
|
|
12
|
+
init: () => void,
|
|
11
13
|
/**
|
|
12
14
|
* Create a state
|
|
13
15
|
* @param name - Name of the gstate
|
|
@@ -44,6 +46,8 @@ interface _gState {
|
|
|
44
46
|
list: () => void
|
|
45
47
|
}
|
|
46
48
|
|
|
49
|
+
declare var globoState: () => void
|
|
50
|
+
|
|
47
51
|
declare var gState: _gState
|
|
48
52
|
type gState = _gState
|
|
49
53
|
|
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useState as
|
|
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}};
|