@httpstate/react 0.0.12 → 0.0.14
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 +61 -0
- package/dist/useHttpState.cjs +1 -1
- package/dist/useHttpState.js +1 -1
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# httpstate (react)
|
|
2
|
+
|
|
3
|
+
## Quick Start
|
|
4
|
+
|
|
5
|
+
Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @httpstate/react
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
Import
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
import { useHttpState } from '@httpstate/react';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Pick any valid UUID v4. You can [generate one here](https://uuid.httpstate.com).
|
|
18
|
+
|
|
19
|
+
We'll use `45fb3654-0e92-44da-aa21-ca409c6bdab3` or `45fb36540e9244daaa21ca409c6bdab3 (without dashes).
|
|
20
|
+
|
|
21
|
+
Use `useHttpState(uuid)` as you would do with a React `useState()` hook.
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
const [data, setData] = useHttpState('45fb36540e9244daaa21ca409c6bdab3');
|
|
25
|
+
|
|
26
|
+
setData('Hi! 👋🏻');
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
That's it! 🐙
|
|
30
|
+
|
|
31
|
+
## API
|
|
32
|
+
|
|
33
|
+
### Hook
|
|
34
|
+
|
|
35
|
+
- `useHttpState(uuid)`
|
|
36
|
+
Create a reactive state instance of UUIDv4.
|
|
37
|
+
- `uuid`: The UUID v4 string.
|
|
38
|
+
|
|
39
|
+
- Returns `[state, setState]` where:
|
|
40
|
+
- `state`: The current data (undefined | string).
|
|
41
|
+
- `setState`: The set function that lets you update the state to a different value.
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## About
|
|
46
|
+
|
|
47
|
+
Alex Morales, [moralestapia.com](https://moralestapia.com)
|
|
48
|
+
|
|
49
|
+
Copyright © Alex Morales, 2026
|
|
50
|
+
|
|
51
|
+
## Contact
|
|
52
|
+
|
|
53
|
+
Comments, feature requests, etc. are welcome at **inbox @ httpstate.com**.
|
|
54
|
+
|
|
55
|
+
## License
|
|
56
|
+
|
|
57
|
+
Unless otherwise stated in particular files or directories, this software is free software.
|
|
58
|
+
|
|
59
|
+
You can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
60
|
+
|
|
61
|
+
See [LICENSE](LICENSE) for more information.
|
package/dist/useHttpState.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var f=Object.create;var s=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var c=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var p=(t,e)=>{for(var n in e)s(t,n,{get:e[n],enumerable:!0})},u=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of o(e))!m.call(t,r)&&r!==n&&s(t,r,{get:()=>e[r],enumerable:!(i=g(e,r))||i.enumerable});return t};var S=(t,e,n)=>(n=t!=null?f(c(t)):{},u(e||!t||!t.__esModule?s(n,"default",{value:t,enumerable:!0}):n,t)),h=t=>u(s({},"__esModule",{value:!0}),t);var P={};p(P,{useHttpState:()=>b});module.exports=h(P);var d=S(require("@httpstate/typescript"),1),a=require("react"),b=t=>{if(!t)return;let[e,n]=(0,a.useState)(void 0);return(0,a.useEffect)(()=>((async()=>{let i=(0,d.default)(t).on("change",r=>n(r));i.emit("change",await i.get())})(),()=>{}),[]),[e,i=>(0,d.set)(t,i)]};0&&(module.exports={useHttpState});
|
package/dist/useHttpState.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import s,{set as
|
|
1
|
+
import s,{set as d}from"@httpstate/typescript";import{useEffect as a,useState as u}from"react";var o=e=>{if(!e)return;let[n,i]=u(void 0);return a(()=>((async()=>{let t=s(e).on("change",r=>i(r));t.emit("change",await t.get())})(),()=>{}),[]),[n,t=>d(e,t)]};export{o as useHttpState};
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"main": "dist/useHttpState.js",
|
|
16
16
|
"name": "@httpstate/react",
|
|
17
17
|
"peerDependencies": {
|
|
18
|
-
"@httpstate/typescript": "^0.0.
|
|
18
|
+
"@httpstate/typescript": "^0.0.36",
|
|
19
19
|
"react": "^19.2.4"
|
|
20
20
|
},
|
|
21
21
|
"repository": {
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
},
|
|
30
30
|
"type": "module",
|
|
31
31
|
"types": "dist/useHttpState.d.ts",
|
|
32
|
-
"version": "0.0.
|
|
32
|
+
"version": "0.0.14"
|
|
33
33
|
}
|