mobx-state-tree 5.1.8 → 5.2.0-alpha.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.
@@ -12,6 +12,10 @@ export interface IMiddlewareEvent extends IActionContext {
12
12
  /** Id of all events, from root until current (excluding current) */
13
13
  readonly allParentIds: number[];
14
14
  }
15
+ export interface FunctionWithFlag extends Function {
16
+ _isMSTAction?: boolean;
17
+ _isFlowAction?: boolean;
18
+ }
15
19
  export declare type IMiddlewareHandler = (actionCall: IMiddlewareEvent, next: (actionCall: IMiddlewareEvent, callback?: (value: any) => any) => void, abort: (value: any) => void) => any;
16
20
  /**
17
21
  * Middleware can be used to intercept any action is invoked on the subtree where it is attached.
@@ -28,7 +28,7 @@ export declare function getChildType(object: IAnyStateTreeNode, propertyName?: s
28
28
  /**
29
29
  * Registers a function that will be invoked for each mutation that is applied to the provided model instance, or to any of its children.
30
30
  * See [patches](https://github.com/mobxjs/mobx-state-tree#patches) for more details. onPatch events are emitted immediately and will not await the end of a transaction.
31
- * Patches can be used to deep observe a model tree.
31
+ * Patches can be used to deeply observe a model tree.
32
32
  *
33
33
  * @param target the model instance from which to receive patches
34
34
  * @param callback the callback that is invoked for each patch. The reversePatch is a patch that would actually undo the emitted patch
@@ -68,7 +68,7 @@ export interface IPatchRecorder {
68
68
  }
69
69
  /**
70
70
  * Small abstraction around `onPatch` and `applyPatch`, attaches a patch listener to a tree and records all the patches.
71
- * Returns an recorder object with the following signature:
71
+ * Returns a recorder object with the following signature:
72
72
  *
73
73
  * Example:
74
74
  * ```ts
@@ -247,7 +247,7 @@ export declare function resolveIdentifier<IT extends IAnyModelType>(type: IT, ta
247
247
  */
248
248
  export declare function getIdentifier(target: IAnyStateTreeNode): string | null;
249
249
  /**
250
- * Tests if a reference is valid (pointing to an existing node and optionally if alive) and returns such reference if it the check passes,
250
+ * Tests if a reference is valid (pointing to an existing node and optionally if alive) and returns such reference if the check passes,
251
251
  * else it returns undefined.
252
252
  *
253
253
  * @param getter Function to access the reference.
@@ -282,9 +282,9 @@ export declare function tryResolve(target: IAnyStateTreeNode, path: string): any
282
282
  export declare function getRelativePath(base: IAnyStateTreeNode, target: IAnyStateTreeNode): string;
283
283
  /**
284
284
  * Returns a deep copy of the given state tree node as new tree.
285
- * Short hand for `snapshot(x) = getType(x).create(getSnapshot(x))`
285
+ * Shorthand for `snapshot(x) = getType(x).create(getSnapshot(x))`
286
286
  *
287
- * _Tip: clone will create a literal copy, including the same identifiers. To modify identifiers etc during cloning, don't use clone but take a snapshot of the tree, modify it, and create new instance_
287
+ * _Tip: clone will create a literal copy, including the same identifiers. To modify identifiers etc. during cloning, don't use clone but take a snapshot of the tree, modify it, and create new instance_
288
288
  *
289
289
  * @param source
290
290
  * @param keepEnvironment indicates whether the clone should inherit the same environment (`true`, the default), or not have an environment (`false`). If an object is passed in as second argument, that will act as the environment for the cloned tree.
@@ -372,9 +372,17 @@ export interface IModelReflectionData extends IModelReflectionPropertiesData {
372
372
  actions: string[];
373
373
  views: string[];
374
374
  volatile: string[];
375
+ flowActions: string[];
375
376
  }
376
377
  /**
377
- * Returns a reflection of the model node, including name, properties, views, volatile and actions.
378
+ * Returns a reflection of the model node, including name, properties, views, volatile state,
379
+ * and actions. `flowActions` is also provided as a separate array of names for any action that
380
+ * came from a flow generator as well.
381
+ *
382
+ * In the case where a model has two actions: `doSomething` and `doSomethingWithFlow`, where
383
+ * `doSomethingWithFlow` is a flow generator, the `actions` array will contain both actions,
384
+ * i.e. ["doSomething", "doSomethingWithFlow"], and the `flowActions` array will contain only
385
+ * the flow action, i.e. ["doSomethingWithFlow"].
378
386
  *
379
387
  * @param target
380
388
  * @returns
@@ -383,7 +391,7 @@ export declare function getMembers(target: IAnyStateTreeNode): IModelReflectionD
383
391
  export declare function cast<O extends string | number | boolean | null | undefined = never>(snapshotOrInstance: O): O;
384
392
  export declare function cast<O = never>(snapshotOrInstance: TypeOfValue<O>["CreationType"] | TypeOfValue<O>["SnapshotType"] | TypeOfValue<O>["Type"]): O;
385
393
  /**
386
- * Casts a node instance type to an snapshot type so it can be assigned to a type snapshot (e.g. to be used inside a create call).
394
+ * Casts a node instance type to a snapshot type so it can be assigned to a type snapshot (e.g. to be used inside a create call).
387
395
  * Note that this is just a cast for the type system, this is, it won't actually convert an instance to a snapshot,
388
396
  * but just fool typescript into thinking so.
389
397
  *
@@ -407,12 +415,12 @@ export declare function cast<O = never>(snapshotOrInstance: TypeOfValue<O>["Crea
407
415
  * ```
408
416
  *
409
417
  * @param snapshotOrInstance Snapshot or instance
410
- * @returns The same object casted as an input (creation) snapshot
418
+ * @returns The same object cast as an input (creation) snapshot
411
419
  */
412
420
  export declare function castToSnapshot<I>(snapshotOrInstance: I): Extract<I, IAnyStateTreeNode> extends never ? I : TypeOfValue<I>["CreationType"];
413
421
  /**
414
- * Casts a node instance type to a reference snapshot type so it can be assigned to a refernence snapshot (e.g. to be used inside a create call).
415
- * Note that this is just a cast for the type system, this is, it won't actually convert an instance to a refererence snapshot,
422
+ * Casts a node instance type to a reference snapshot type so it can be assigned to a reference snapshot (e.g. to be used inside a create call).
423
+ * Note that this is just a cast for the type system, this is, it won't actually convert an instance to a reference snapshot,
416
424
  * but just fool typescript into thinking so.
417
425
  *
418
426
  * Example:
@@ -436,7 +444,7 @@ export declare function castToSnapshot<I>(snapshotOrInstance: I): Extract<I, IAn
436
444
  * ```
437
445
  *
438
446
  * @param instance Instance
439
- * @returns The same object casted as an reference snapshot (string or number)
447
+ * @returns The same object cast as a reference snapshot (string or number)
440
448
  */
441
449
  export declare function castToReferenceSnapshot<I>(instance: I): Extract<I, IAnyStateTreeNode> extends never ? I : ReferenceIdentifier;
442
450
  /**
@@ -30,6 +30,7 @@ export * from "./types/utility-types/union";
30
30
  export * from "./types/utility-types/optional";
31
31
  export * from "./types/utility-types/maybe";
32
32
  export * from "./types/utility-types/late";
33
+ export * from "./types/utility-types/lazy";
33
34
  export * from "./types/utility-types/frozen";
34
35
  export * from "./types/utility-types/reference";
35
36
  export * from "./types/utility-types/identifier";