barrex 0.0.1 → 0.0.2

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 (3) hide show
  1. package/LICENSE +9 -0
  2. package/README.md +73 -0
  3. package/package.json +6 -6
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bhuvan Dahal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,73 @@
1
+ # barrex
2
+
3
+ > The bare essentials for state management in React.
4
+
5
+ `barrex` is a lightweight, explicit, and fully-typed React state management library built on a proxy-driven path architecture. Designed as a predictable, no-magic alternative, it gives you fine-grained reactivity with a clean `.get()`, `.set()`, and `.subscribe()` API powered by `useSyncExternalStore`.
6
+
7
+ ---
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install barrex
13
+ ```
14
+
15
+ _(Requires `react` >= 18 as a peer dependency)_
16
+
17
+ ---
18
+
19
+ ## Quick Start
20
+
21
+ ### 1. Create a Notifier
22
+
23
+ ```ts
24
+ import { createNotifier } from "barrex";
25
+
26
+ // Define your plain state object type
27
+ interface AppState {
28
+ count: number;
29
+ user: {
30
+ name: string;
31
+ isLoggedIn: boolean;
32
+ };
33
+ }
34
+
35
+ // Create the notifier
36
+ export const appNotifier = createNotifier<AppState>({
37
+ count: 0,
38
+ user: {
39
+ name: "Alice",
40
+ isLoggedIn: false
41
+ }
42
+ });
43
+ ```
44
+
45
+ ### 2. Use in React Components
46
+
47
+ ```tsx
48
+ import { useListener } from "barrex";
49
+
50
+ import { appNotifier } from "./app-notifier";
51
+
52
+ export function Counter() {
53
+ // Fine-grained subscription: component only re-renders when `count` changes
54
+ const count = useListener(appNotifier.count);
55
+
56
+ return (
57
+ <div>
58
+ <p>Count: {count}</p>
59
+ {/* Explicit .set() method with updater support */}
60
+ <button onClick={() => appNotifier.count.set((c) => c + 1)}>
61
+ Increment
62
+ </button>
63
+ <button onClick={() => appNotifier.count.set(0)}>Reset</button>
64
+ </div>
65
+ );
66
+ }
67
+ ```
68
+
69
+ ---
70
+
71
+ ## License
72
+
73
+ [MIT](https://github.com/bhuvanpddahal/barrex/blob/HEAD/LICENSE)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "barrex",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "The bare essentials for state management in React",
5
5
  "homepage": "https://github.com/bhuvanpddahal/barrex#readme",
6
6
  "repository": {
@@ -10,17 +10,17 @@
10
10
  "bugs": {
11
11
  "url": "https://github.com/bhuvanpddahal/barrex/issues"
12
12
  },
13
- "author": "Bhuvan Dahal",
13
+ "author": "Bhuvan Dahal <bhuvandahal6@gmail.com>",
14
14
  "license": "MIT",
15
15
  "type": "module",
16
- "main": "./dist/index.js",
17
- "module": "./dist/index.mjs",
16
+ "main": "./dist/index.cjs",
17
+ "module": "./dist/index.js",
18
18
  "types": "./dist/index.d.ts",
19
19
  "exports": {
20
20
  ".": {
21
21
  "types": "./dist/index.d.ts",
22
- "import": "./dist/index.mjs",
23
- "require": "./dist/index.js"
22
+ "import": "./dist/index.js",
23
+ "require": "./dist/index.cjs"
24
24
  }
25
25
  },
26
26
  "files": [