as-model 0.1.12 → 0.1.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.
Files changed (2) hide show
  1. package/index.d.ts +18 -16
  2. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -3,8 +3,24 @@ declare interface ModelInstance {
3
3
  [key: number]: any;
4
4
  }
5
5
 
6
+ declare type FieldStructure<R = any> = {
7
+ callback: () => R;
8
+ deps: any[] | undefined;
9
+ identifier: (d: any) => d is FieldStructure<R>;
10
+ value: R;
11
+ get: () => R;
12
+ };
13
+
14
+ declare type MethodStructure<
15
+ R extends (...args: any[]) => any = (...args: any[]) => any
16
+ > = R & {
17
+ identifier: (d: any) => d is MethodStructure;
18
+ };
19
+
6
20
  declare type ValidInstance<S, T extends ModelInstance> = {
7
- [K in keyof T]: T[K] extends (...args: any[]) => S
21
+ [K in keyof T]: T[K] extends
22
+ | ((...args: any[]) => S)
23
+ | (((...args: any[]) => any) & { identifier: (d: any) => boolean })
8
24
  ? T[K]
9
25
  : T[K] extends (...args: any[]) => any
10
26
  ? never
@@ -78,7 +94,7 @@ export declare interface Store<
78
94
  > extends StoreIndex<S, T, R> {
79
95
  subscribe: (dispatcher: Dispatch) => () => void;
80
96
  getInstance: () => T;
81
- update: (args?: { model?: Model<S, T>; state?: S }) => void;
97
+ update: (args?: { model?: Model<S, T>; initialState?: S; state?: S }) => void;
82
98
  destroy: () => void;
83
99
  payload: <P>(
84
100
  callback?: (payload: P | undefined) => P | undefined
@@ -152,20 +168,6 @@ export declare interface ModelUsage<
152
168
  extends: <E extends Record<string, any>>(e: E) => ModelUsage<S, T, R> & E;
153
169
  }
154
170
 
155
- declare type FieldStructure<R = any> = {
156
- callback: () => R;
157
- deps: any[] | undefined;
158
- identifier: (d: any) => d is FieldStructure<R>;
159
- value: R;
160
- get: () => R;
161
- };
162
-
163
- declare type MethodStructure<
164
- R extends (...args: any[]) => any = (...args: any[]) => any
165
- > = R & {
166
- identifier: (d: any) => d is MethodStructure;
167
- };
168
-
169
171
  // eslint-disable-next-line @typescript-eslint/naming-convention
170
172
  export declare interface model {
171
173
  <
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "private": false,
3
3
  "name": "as-model",
4
- "version": "0.1.12",
4
+ "version": "0.1.14",
5
5
  "description": "This is a model state management tool",
6
6
  "license": "MIT",
7
7
  "author": "Jimmy.Harding",