r-state-tree 0.7.0 → 0.8.0

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.
@@ -8,13 +8,14 @@ type CreateStoreProps<T extends Record<string, any>> = {
8
8
  export declare function createStore<K extends Store<any>, T extends Record<string, any> = K extends Store<infer P> ? P : never>(Type: new (props: StoreProps<T>) => K, props?: CreateStoreProps<T>): K;
9
9
  export declare function updateStore<K extends Store<T>, T extends Record<string, any>>(store: K, props: CreateStoreProps<T>): K;
10
10
  export declare function types<T extends Store>(config: Partial<StoreConfiguration<T>>): Partial<StoreConfiguration<T>>;
11
- export default class Store<PropsType extends Record<string, any> = StoreProps<Props>> {
11
+ export default class Store<PropsType extends Record<string, any> = StoreProps<Props>> implements Disposable {
12
12
  static types?: StoreConfiguration<unknown>;
13
13
  props: StoreProps<PropsType>;
14
14
  constructor(props: StoreProps<PropsType>);
15
15
  get key(): string | number | undefined;
16
- reaction<T>(track: () => T, callback: (a: T) => void): () => void;
17
- storeDidMount(): void;
18
- storeWillUnmount(): void;
16
+ get isMounted(): boolean;
17
+ reaction<T>(track: () => T, callback: (value: T, previousValue: T) => void): () => void;
18
+ effect(callback: () => void | (() => void)): () => void;
19
+ [Symbol.dispose](): void;
19
20
  }
20
21
  export {};
@@ -6,10 +6,11 @@ export declare function getStoreAdm(store: Store): StoreAdministration;
6
6
  export declare class StoreAdministration<StoreType extends Store = Store> extends ObjectAdministration<Store> {
7
7
  static proxyTraps: ProxyHandler<object>;
8
8
  parent: StoreAdministration | null;
9
- mounted: boolean;
9
+ private mountedSignal;
10
+ private disposed;
10
11
  private contextCache;
11
12
  private childStoreDataMap;
12
- private reactionsUnsub;
13
+ private ownedDisposers;
13
14
  private configurationGetter?;
14
15
  setConfiguration(configurationGetter: () => StoreConfiguration<StoreType>): void;
15
16
  private get configuration();
@@ -22,9 +23,12 @@ export declare class StoreAdministration<StoreType extends Store = Store> extend
22
23
  private getStore;
23
24
  private getModelRef;
24
25
  isRoot(): boolean;
26
+ get isMounted(): boolean;
25
27
  getContextValue<T>(contextId: symbol, provideSymbol: symbol, defaultValue: T | undefined, hasDefault: boolean): T;
26
28
  private lookupContextValue;
27
- reaction<T>(track: () => T, callback: (a: T) => void): () => void;
29
+ private own;
30
+ reaction<T>(track: () => T, callback: (value: T, previousValue: T) => void): () => void;
31
+ effect(callback: () => void | (() => void)): () => void;
28
32
  mount(parent?: StoreAdministration | null, childName?: PropertyKey): void;
29
- unmount(): void;
33
+ dispose(internal?: boolean): void;
30
34
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "r-state-tree",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "reactive state management library",
5
5
  "main": "dist/r-state-tree.cjs",
6
6
  "module": "dist/r-state-tree.js",