bunja 0.0.8 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Bunja
2
2
 
3
- Bunja is State Lifetime Manager for React. (Minified & gzipped size < 1kB)\
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
- effect() {
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunja",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "description": "State Lifetime Manager",
5
5
  "main": "bunja.ts",
6
6
  "scripts": {},
package/react.ts CHANGED
@@ -22,13 +22,12 @@ export function createScopeFromContext<T>(context: Context<T>): Scope<T> {
22
22
 
23
23
  const defaultReadScope: ReadScope = (scope) => {
24
24
  const context = scopeContextMap.get(scope)!;
25
- console.log({ scopeContextMap, scope, context });
26
25
  return useContext(context);
27
26
  };
28
27
 
29
28
  export function useBunja<T>(bunja: Bunja<T>, readScope = defaultReadScope): T {
30
29
  const store = useContext(BunjaStoreContext);
31
- const { value, effect } = store.get(bunja, readScope);
32
- useEffect(effect, []);
30
+ const { value, mount } = store.get(bunja, readScope);
31
+ useEffect(mount, []);
33
32
  return value;
34
33
  }