bunja 0.0.9 → 0.0.10
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 +1 -1
- package/bunja.ts +2 -2
- package/package.json +1 -1
- package/react.ts +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Bunja
|
|
2
2
|
|
|
3
|
-
Bunja is State Lifetime Manager
|
|
3
|
+
Bunja is lightweight State Lifetime Manager.\
|
|
4
4
|
Heavily inspired by [Bunshi](https://github.com/saasquatch/bunshi).
|
|
5
5
|
|
|
6
6
|
> Definition: Bunja (分子 / 분자) - Korean for molecule, member or element.
|
package/bunja.ts
CHANGED
|
@@ -48,11 +48,11 @@ export class BunjaStore {
|
|
|
48
48
|
const { relatedBunjaInstanceMap } = bunjaInstance; // toposorted
|
|
49
49
|
return {
|
|
50
50
|
value: bunjaInstance.value as T,
|
|
51
|
-
|
|
51
|
+
mount() {
|
|
52
52
|
relatedBunjaInstanceMap.forEach((related) => related.add());
|
|
53
53
|
bunjaInstance.add();
|
|
54
54
|
scopeInstanceMap.forEach((scope) => scope.add());
|
|
55
|
-
return ()
|
|
55
|
+
return function unmount() {
|
|
56
56
|
// concern: reverse order?
|
|
57
57
|
relatedBunjaInstanceMap.forEach((related) => related.sub());
|
|
58
58
|
bunjaInstance.sub();
|
package/package.json
CHANGED
package/react.ts
CHANGED
|
@@ -27,7 +27,7 @@ const defaultReadScope: ReadScope = (scope) => {
|
|
|
27
27
|
|
|
28
28
|
export function useBunja<T>(bunja: Bunja<T>, readScope = defaultReadScope): T {
|
|
29
29
|
const store = useContext(BunjaStoreContext);
|
|
30
|
-
const { value,
|
|
31
|
-
useEffect(
|
|
30
|
+
const { value, mount } = store.get(bunja, readScope);
|
|
31
|
+
useEffect(mount, []);
|
|
32
32
|
return value;
|
|
33
33
|
}
|