@jbrowse/mobx-state-tree 5.7.0 → 5.8.6
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 +0 -10
- package/dist/index.d.ts +2135 -2
- package/dist/mobx-state-tree.cjs +6894 -0
- package/dist/mobx-state-tree.cjs.map +1 -0
- package/dist/mobx-state-tree.mjs +6814 -0
- package/dist/mobx-state-tree.mjs.map +1 -0
- package/package.json +30 -26
- package/dist/core/action.d.ts +0 -87
- package/dist/core/action.js +0 -228
- package/dist/core/action.js.map +0 -1
- package/dist/core/actionContext.d.ts +0 -27
- package/dist/core/actionContext.js +0 -42
- package/dist/core/actionContext.js.map +0 -1
- package/dist/core/flow.d.ts +0 -69
- package/dist/core/flow.js +0 -180
- package/dist/core/flow.js.map +0 -1
- package/dist/core/json-patch.d.ts +0 -46
- package/dist/core/json-patch.js +0 -133
- package/dist/core/json-patch.js.map +0 -1
- package/dist/core/mst-operations.d.ts +0 -459
- package/dist/core/mst-operations.js +0 -885
- package/dist/core/mst-operations.js.map +0 -1
- package/dist/core/node/BaseNode.d.ts +0 -62
- package/dist/core/node/BaseNode.js +0 -152
- package/dist/core/node/BaseNode.js.map +0 -1
- package/dist/core/node/Hook.d.ts +0 -17
- package/dist/core/node/Hook.js +0 -15
- package/dist/core/node/Hook.js.map +0 -1
- package/dist/core/node/create-node.d.ts +0 -16
- package/dist/core/node/create-node.js +0 -41
- package/dist/core/node/create-node.js.map +0 -1
- package/dist/core/node/identifier-cache.d.ts +0 -19
- package/dist/core/node/identifier-cache.js +0 -115
- package/dist/core/node/identifier-cache.js.map +0 -1
- package/dist/core/node/livelinessChecking.d.ts +0 -37
- package/dist/core/node/livelinessChecking.js +0 -38
- package/dist/core/node/livelinessChecking.js.map +0 -1
- package/dist/core/node/node-utils.d.ts +0 -83
- package/dist/core/node/node-utils.js +0 -165
- package/dist/core/node/node-utils.js.map +0 -1
- package/dist/core/node/object-node.d.ts +0 -101
- package/dist/core/node/object-node.js +0 -546
- package/dist/core/node/object-node.js.map +0 -1
- package/dist/core/node/scalar-node.d.ts +0 -21
- package/dist/core/node/scalar-node.js +0 -90
- package/dist/core/node/scalar-node.js.map +0 -1
- package/dist/core/process.d.ts +0 -50
- package/dist/core/process.js +0 -39
- package/dist/core/process.js.map +0 -1
- package/dist/core/type/type-checker.d.ts +0 -69
- package/dist/core/type/type-checker.js +0 -154
- package/dist/core/type/type-checker.js.map +0 -1
- package/dist/core/type/type.d.ts +0 -317
- package/dist/core/type/type.js +0 -251
- package/dist/core/type/type.js.map +0 -1
- package/dist/index.js +0 -85
- package/dist/index.js.map +0 -1
- package/dist/internal.d.ts +0 -39
- package/dist/internal.js +0 -60
- package/dist/internal.js.map +0 -1
- package/dist/middlewares/create-action-tracking-middleware.d.ts +0 -24
- package/dist/middlewares/create-action-tracking-middleware.js +0 -81
- package/dist/middlewares/create-action-tracking-middleware.js.map +0 -1
- package/dist/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
- package/dist/middlewares/createActionTrackingMiddleware2.js +0 -133
- package/dist/middlewares/createActionTrackingMiddleware2.js.map +0 -1
- package/dist/middlewares/on-action.d.ts +0 -87
- package/dist/middlewares/on-action.js +0 -215
- package/dist/middlewares/on-action.js.map +0 -1
- package/dist/package.json +0 -1
- package/dist/types/complex-types/array.d.ts +0 -81
- package/dist/types/complex-types/array.js +0 -353
- package/dist/types/complex-types/array.js.map +0 -1
- package/dist/types/complex-types/map.d.ts +0 -111
- package/dist/types/complex-types/map.js +0 -362
- package/dist/types/complex-types/map.js.map +0 -1
- package/dist/types/complex-types/model.d.ts +0 -193
- package/dist/types/complex-types/model.js +0 -478
- package/dist/types/complex-types/model.js.map +0 -1
- package/dist/types/index.d.ts +0 -33
- package/dist/types/index.js +0 -38
- package/dist/types/index.js.map +0 -1
- package/dist/types/primitives.d.ts +0 -125
- package/dist/types/primitives.js +0 -183
- package/dist/types/primitives.js.map +0 -1
- package/dist/types/utility-types/custom.d.ts +0 -75
- package/dist/types/utility-types/custom.js +0 -111
- package/dist/types/utility-types/custom.js.map +0 -1
- package/dist/types/utility-types/enumeration.d.ts +0 -5
- package/dist/types/utility-types/enumeration.js +0 -34
- package/dist/types/utility-types/enumeration.js.map +0 -1
- package/dist/types/utility-types/frozen.d.ts +0 -24
- package/dist/types/utility-types/frozen.js +0 -98
- package/dist/types/utility-types/frozen.js.map +0 -1
- package/dist/types/utility-types/identifier.d.ts +0 -87
- package/dist/types/utility-types/identifier.js +0 -130
- package/dist/types/utility-types/identifier.js.map +0 -1
- package/dist/types/utility-types/late.d.ts +0 -10
- package/dist/types/utility-types/late.js +0 -110
- package/dist/types/utility-types/late.js.map +0 -1
- package/dist/types/utility-types/lazy.d.ts +0 -23
- package/dist/types/utility-types/lazy.js +0 -77
- package/dist/types/utility-types/lazy.js.map +0 -1
- package/dist/types/utility-types/literal.d.ts +0 -38
- package/dist/types/utility-types/literal.js +0 -64
- package/dist/types/utility-types/literal.js.map +0 -1
- package/dist/types/utility-types/maybe.d.ts +0 -26
- package/dist/types/utility-types/maybe.js +0 -30
- package/dist/types/utility-types/maybe.js.map +0 -1
- package/dist/types/utility-types/optional.d.ts +0 -42
- package/dist/types/utility-types/optional.js +0 -141
- package/dist/types/utility-types/optional.js.map +0 -1
- package/dist/types/utility-types/reference.d.ts +0 -90
- package/dist/types/utility-types/reference.js +0 -393
- package/dist/types/utility-types/reference.js.map +0 -1
- package/dist/types/utility-types/refinement.d.ts +0 -10
- package/dist/types/utility-types/refinement.js +0 -86
- package/dist/types/utility-types/refinement.js.map +0 -1
- package/dist/types/utility-types/resilient.d.ts +0 -18
- package/dist/types/utility-types/resilient.js +0 -121
- package/dist/types/utility-types/resilient.js.map +0 -1
- package/dist/types/utility-types/snapshotProcessor.d.ts +0 -63
- package/dist/types/utility-types/snapshotProcessor.js +0 -162
- package/dist/types/utility-types/snapshotProcessor.js.map +0 -1
- package/dist/types/utility-types/union.d.ts +0 -78
- package/dist/types/utility-types/union.js +0 -246
- package/dist/types/utility-types/union.js.map +0 -1
- package/dist/utils.d.ts +0 -230
- package/dist/utils.js +0 -483
- package/dist/utils.js.map +0 -1
- package/esm/core/action.d.ts +0 -87
- package/esm/core/action.js +0 -219
- package/esm/core/action.js.map +0 -1
- package/esm/core/actionContext.d.ts +0 -27
- package/esm/core/actionContext.js +0 -37
- package/esm/core/actionContext.js.map +0 -1
- package/esm/core/flow.d.ts +0 -69
- package/esm/core/flow.js +0 -173
- package/esm/core/flow.js.map +0 -1
- package/esm/core/json-patch.d.ts +0 -46
- package/esm/core/json-patch.js +0 -125
- package/esm/core/json-patch.js.map +0 -1
- package/esm/core/mst-operations.d.ts +0 -459
- package/esm/core/mst-operations.js +0 -844
- package/esm/core/mst-operations.js.map +0 -1
- package/esm/core/node/BaseNode.d.ts +0 -62
- package/esm/core/node/BaseNode.js +0 -148
- package/esm/core/node/BaseNode.js.map +0 -1
- package/esm/core/node/Hook.d.ts +0 -17
- package/esm/core/node/Hook.js +0 -12
- package/esm/core/node/Hook.js.map +0 -1
- package/esm/core/node/create-node.d.ts +0 -16
- package/esm/core/node/create-node.js +0 -36
- package/esm/core/node/create-node.js.map +0 -1
- package/esm/core/node/identifier-cache.d.ts +0 -19
- package/esm/core/node/identifier-cache.js +0 -111
- package/esm/core/node/identifier-cache.js.map +0 -1
- package/esm/core/node/livelinessChecking.d.ts +0 -37
- package/esm/core/node/livelinessChecking.js +0 -33
- package/esm/core/node/livelinessChecking.js.map +0 -1
- package/esm/core/node/node-utils.d.ts +0 -83
- package/esm/core/node/node-utils.js +0 -153
- package/esm/core/node/node-utils.js.map +0 -1
- package/esm/core/node/object-node.d.ts +0 -101
- package/esm/core/node/object-node.js +0 -542
- package/esm/core/node/object-node.js.map +0 -1
- package/esm/core/node/scalar-node.d.ts +0 -21
- package/esm/core/node/scalar-node.js +0 -86
- package/esm/core/node/scalar-node.js.map +0 -1
- package/esm/core/process.d.ts +0 -50
- package/esm/core/process.js +0 -35
- package/esm/core/process.js.map +0 -1
- package/esm/core/type/type-checker.d.ts +0 -69
- package/esm/core/type/type-checker.js +0 -144
- package/esm/core/type/type-checker.js.map +0 -1
- package/esm/core/type/type.d.ts +0 -317
- package/esm/core/type/type.js +0 -243
- package/esm/core/type/type.js.map +0 -1
- package/esm/index.d.ts +0 -2
- package/esm/index.js +0 -2
- package/esm/index.js.map +0 -1
- package/esm/internal.d.ts +0 -39
- package/esm/internal.js +0 -44
- package/esm/internal.js.map +0 -1
- package/esm/middlewares/create-action-tracking-middleware.d.ts +0 -24
- package/esm/middlewares/create-action-tracking-middleware.js +0 -78
- package/esm/middlewares/create-action-tracking-middleware.js.map +0 -1
- package/esm/middlewares/createActionTrackingMiddleware2.d.ts +0 -34
- package/esm/middlewares/createActionTrackingMiddleware2.js +0 -130
- package/esm/middlewares/createActionTrackingMiddleware2.js.map +0 -1
- package/esm/middlewares/on-action.d.ts +0 -87
- package/esm/middlewares/on-action.js +0 -210
- package/esm/middlewares/on-action.js.map +0 -1
- package/esm/types/complex-types/array.d.ts +0 -81
- package/esm/types/complex-types/array.js +0 -347
- package/esm/types/complex-types/array.js.map +0 -1
- package/esm/types/complex-types/map.d.ts +0 -111
- package/esm/types/complex-types/map.js +0 -356
- package/esm/types/complex-types/map.js.map +0 -1
- package/esm/types/complex-types/model.d.ts +0 -193
- package/esm/types/complex-types/model.js +0 -471
- package/esm/types/complex-types/model.js.map +0 -1
- package/esm/types/index.d.ts +0 -33
- package/esm/types/index.js +0 -35
- package/esm/types/index.js.map +0 -1
- package/esm/types/primitives.d.ts +0 -125
- package/esm/types/primitives.js +0 -177
- package/esm/types/primitives.js.map +0 -1
- package/esm/types/utility-types/custom.d.ts +0 -75
- package/esm/types/utility-types/custom.js +0 -106
- package/esm/types/utility-types/custom.js.map +0 -1
- package/esm/types/utility-types/enumeration.d.ts +0 -5
- package/esm/types/utility-types/enumeration.js +0 -31
- package/esm/types/utility-types/enumeration.js.map +0 -1
- package/esm/types/utility-types/frozen.d.ts +0 -24
- package/esm/types/utility-types/frozen.js +0 -92
- package/esm/types/utility-types/frozen.js.map +0 -1
- package/esm/types/utility-types/identifier.d.ts +0 -87
- package/esm/types/utility-types/identifier.js +0 -121
- package/esm/types/utility-types/identifier.js.map +0 -1
- package/esm/types/utility-types/late.d.ts +0 -10
- package/esm/types/utility-types/late.js +0 -106
- package/esm/types/utility-types/late.js.map +0 -1
- package/esm/types/utility-types/lazy.d.ts +0 -23
- package/esm/types/utility-types/lazy.js +0 -72
- package/esm/types/utility-types/lazy.js.map +0 -1
- package/esm/types/utility-types/literal.d.ts +0 -38
- package/esm/types/utility-types/literal.js +0 -58
- package/esm/types/utility-types/literal.js.map +0 -1
- package/esm/types/utility-types/maybe.d.ts +0 -26
- package/esm/types/utility-types/maybe.js +0 -26
- package/esm/types/utility-types/maybe.js.map +0 -1
- package/esm/types/utility-types/optional.d.ts +0 -42
- package/esm/types/utility-types/optional.js +0 -135
- package/esm/types/utility-types/optional.js.map +0 -1
- package/esm/types/utility-types/reference.d.ts +0 -90
- package/esm/types/utility-types/reference.js +0 -383
- package/esm/types/utility-types/reference.js.map +0 -1
- package/esm/types/utility-types/refinement.d.ts +0 -10
- package/esm/types/utility-types/refinement.js +0 -82
- package/esm/types/utility-types/refinement.js.map +0 -1
- package/esm/types/utility-types/resilient.d.ts +0 -18
- package/esm/types/utility-types/resilient.js +0 -118
- package/esm/types/utility-types/resilient.js.map +0 -1
- package/esm/types/utility-types/snapshotProcessor.d.ts +0 -63
- package/esm/types/utility-types/snapshotProcessor.js +0 -159
- package/esm/types/utility-types/snapshotProcessor.js.map +0 -1
- package/esm/types/utility-types/union.d.ts +0 -78
- package/esm/types/utility-types/union.js +0 -240
- package/esm/types/utility-types/union.js.map +0 -1
- package/esm/utils.d.ts +0 -230
- package/esm/utils.js +0 -449
- package/esm/utils.js.map +0 -1
package/dist/index.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRefinementType = exports.isReferenceType = exports.isProtected = exports.isPrimitiveType = exports.isOptionalType = exports.isModelType = exports.isMapType = exports.isLiteralType = exports.isLateType = exports.isIdentifierType = exports.isFrozenType = exports.isArrayType = exports.isAlive = exports.isActionContextThisOrChildOf = exports.isActionContextChildOf = exports.hasParentOfType = exports.hasParent = exports.getType = exports.getSnapshot = exports.getRunningActionContext = exports.getRoot = exports.getRelativePath = exports.getPropertyMembers = exports.getPathParts = exports.getPath = exports.getParentOfType = exports.getParent = exports.getNodeId = exports.getMembers = exports.getLivelinessChecking = exports.getIdentifier = exports.getEnv = exports.getChildType = exports.flow = exports.escapeJsonPath = exports.detach = exports.destroy = exports.decorate = exports.createActionTrackingMiddleware = exports.createActionTrackingMiddleware2 = exports.clone = exports.castToSnapshot = exports.castToReferenceSnapshot = exports.castFlowReturn = exports.cast = exports.applySnapshot = exports.applyPatch = exports.applyAction = exports.addMiddleware = exports.addDisposer = void 0;
|
|
4
|
-
exports.setDevMode = exports.walk = exports.unprotect = exports.unescapeJsonPath = exports.t = exports.types = exports.typecheck = exports.tryResolve = exports.tryReference = exports.toGeneratorFunction = exports.toGenerator = exports.splitJsonPath = exports.setLivelynessChecking = exports.setLivelinessChecking = exports.resolvePath = exports.resolveIdentifier = exports.recordPatches = exports.recordActions = exports.protect = exports.process = exports.onSnapshot = exports.onPatch = exports.onAction = exports.joinJsonPath = exports.isValidReference = exports.isUnionType = exports.isType = exports.isStateTreeNode = exports.isRoot = void 0;
|
|
5
|
-
var internal_ts_1 = require("./internal.js");
|
|
6
|
-
Object.defineProperty(exports, "addDisposer", { enumerable: true, get: function () { return internal_ts_1.addDisposer; } });
|
|
7
|
-
Object.defineProperty(exports, "addMiddleware", { enumerable: true, get: function () { return internal_ts_1.addMiddleware; } });
|
|
8
|
-
Object.defineProperty(exports, "applyAction", { enumerable: true, get: function () { return internal_ts_1.applyAction; } });
|
|
9
|
-
Object.defineProperty(exports, "applyPatch", { enumerable: true, get: function () { return internal_ts_1.applyPatch; } });
|
|
10
|
-
Object.defineProperty(exports, "applySnapshot", { enumerable: true, get: function () { return internal_ts_1.applySnapshot; } });
|
|
11
|
-
Object.defineProperty(exports, "cast", { enumerable: true, get: function () { return internal_ts_1.cast; } });
|
|
12
|
-
Object.defineProperty(exports, "castFlowReturn", { enumerable: true, get: function () { return internal_ts_1.castFlowReturn; } });
|
|
13
|
-
Object.defineProperty(exports, "castToReferenceSnapshot", { enumerable: true, get: function () { return internal_ts_1.castToReferenceSnapshot; } });
|
|
14
|
-
Object.defineProperty(exports, "castToSnapshot", { enumerable: true, get: function () { return internal_ts_1.castToSnapshot; } });
|
|
15
|
-
Object.defineProperty(exports, "clone", { enumerable: true, get: function () { return internal_ts_1.clone; } });
|
|
16
|
-
Object.defineProperty(exports, "createActionTrackingMiddleware2", { enumerable: true, get: function () { return internal_ts_1.createActionTrackingMiddleware2; } });
|
|
17
|
-
Object.defineProperty(exports, "createActionTrackingMiddleware", { enumerable: true, get: function () { return internal_ts_1.createActionTrackingMiddleware; } });
|
|
18
|
-
Object.defineProperty(exports, "decorate", { enumerable: true, get: function () { return internal_ts_1.decorate; } });
|
|
19
|
-
Object.defineProperty(exports, "destroy", { enumerable: true, get: function () { return internal_ts_1.destroy; } });
|
|
20
|
-
Object.defineProperty(exports, "detach", { enumerable: true, get: function () { return internal_ts_1.detach; } });
|
|
21
|
-
Object.defineProperty(exports, "escapeJsonPath", { enumerable: true, get: function () { return internal_ts_1.escapeJsonPath; } });
|
|
22
|
-
Object.defineProperty(exports, "flow", { enumerable: true, get: function () { return internal_ts_1.flow; } });
|
|
23
|
-
Object.defineProperty(exports, "getChildType", { enumerable: true, get: function () { return internal_ts_1.getChildType; } });
|
|
24
|
-
Object.defineProperty(exports, "getEnv", { enumerable: true, get: function () { return internal_ts_1.getEnv; } });
|
|
25
|
-
Object.defineProperty(exports, "getIdentifier", { enumerable: true, get: function () { return internal_ts_1.getIdentifier; } });
|
|
26
|
-
Object.defineProperty(exports, "getLivelinessChecking", { enumerable: true, get: function () { return internal_ts_1.getLivelinessChecking; } });
|
|
27
|
-
Object.defineProperty(exports, "getMembers", { enumerable: true, get: function () { return internal_ts_1.getMembers; } });
|
|
28
|
-
Object.defineProperty(exports, "getNodeId", { enumerable: true, get: function () { return internal_ts_1.getNodeId; } });
|
|
29
|
-
Object.defineProperty(exports, "getParent", { enumerable: true, get: function () { return internal_ts_1.getParent; } });
|
|
30
|
-
Object.defineProperty(exports, "getParentOfType", { enumerable: true, get: function () { return internal_ts_1.getParentOfType; } });
|
|
31
|
-
Object.defineProperty(exports, "getPath", { enumerable: true, get: function () { return internal_ts_1.getPath; } });
|
|
32
|
-
Object.defineProperty(exports, "getPathParts", { enumerable: true, get: function () { return internal_ts_1.getPathParts; } });
|
|
33
|
-
Object.defineProperty(exports, "getPropertyMembers", { enumerable: true, get: function () { return internal_ts_1.getPropertyMembers; } });
|
|
34
|
-
Object.defineProperty(exports, "getRelativePath", { enumerable: true, get: function () { return internal_ts_1.getRelativePath; } });
|
|
35
|
-
Object.defineProperty(exports, "getRoot", { enumerable: true, get: function () { return internal_ts_1.getRoot; } });
|
|
36
|
-
Object.defineProperty(exports, "getRunningActionContext", { enumerable: true, get: function () { return internal_ts_1.getRunningActionContext; } });
|
|
37
|
-
Object.defineProperty(exports, "getSnapshot", { enumerable: true, get: function () { return internal_ts_1.getSnapshot; } });
|
|
38
|
-
Object.defineProperty(exports, "getType", { enumerable: true, get: function () { return internal_ts_1.getType; } });
|
|
39
|
-
Object.defineProperty(exports, "hasParent", { enumerable: true, get: function () { return internal_ts_1.hasParent; } });
|
|
40
|
-
Object.defineProperty(exports, "hasParentOfType", { enumerable: true, get: function () { return internal_ts_1.hasParentOfType; } });
|
|
41
|
-
Object.defineProperty(exports, "isActionContextChildOf", { enumerable: true, get: function () { return internal_ts_1.isActionContextChildOf; } });
|
|
42
|
-
Object.defineProperty(exports, "isActionContextThisOrChildOf", { enumerable: true, get: function () { return internal_ts_1.isActionContextThisOrChildOf; } });
|
|
43
|
-
Object.defineProperty(exports, "isAlive", { enumerable: true, get: function () { return internal_ts_1.isAlive; } });
|
|
44
|
-
Object.defineProperty(exports, "isArrayType", { enumerable: true, get: function () { return internal_ts_1.isArrayType; } });
|
|
45
|
-
Object.defineProperty(exports, "isFrozenType", { enumerable: true, get: function () { return internal_ts_1.isFrozenType; } });
|
|
46
|
-
Object.defineProperty(exports, "isIdentifierType", { enumerable: true, get: function () { return internal_ts_1.isIdentifierType; } });
|
|
47
|
-
Object.defineProperty(exports, "isLateType", { enumerable: true, get: function () { return internal_ts_1.isLateType; } });
|
|
48
|
-
Object.defineProperty(exports, "isLiteralType", { enumerable: true, get: function () { return internal_ts_1.isLiteralType; } });
|
|
49
|
-
Object.defineProperty(exports, "isMapType", { enumerable: true, get: function () { return internal_ts_1.isMapType; } });
|
|
50
|
-
Object.defineProperty(exports, "isModelType", { enumerable: true, get: function () { return internal_ts_1.isModelType; } });
|
|
51
|
-
Object.defineProperty(exports, "isOptionalType", { enumerable: true, get: function () { return internal_ts_1.isOptionalType; } });
|
|
52
|
-
Object.defineProperty(exports, "isPrimitiveType", { enumerable: true, get: function () { return internal_ts_1.isPrimitiveType; } });
|
|
53
|
-
Object.defineProperty(exports, "isProtected", { enumerable: true, get: function () { return internal_ts_1.isProtected; } });
|
|
54
|
-
Object.defineProperty(exports, "isReferenceType", { enumerable: true, get: function () { return internal_ts_1.isReferenceType; } });
|
|
55
|
-
Object.defineProperty(exports, "isRefinementType", { enumerable: true, get: function () { return internal_ts_1.isRefinementType; } });
|
|
56
|
-
Object.defineProperty(exports, "isRoot", { enumerable: true, get: function () { return internal_ts_1.isRoot; } });
|
|
57
|
-
Object.defineProperty(exports, "isStateTreeNode", { enumerable: true, get: function () { return internal_ts_1.isStateTreeNode; } });
|
|
58
|
-
Object.defineProperty(exports, "isType", { enumerable: true, get: function () { return internal_ts_1.isType; } });
|
|
59
|
-
Object.defineProperty(exports, "isUnionType", { enumerable: true, get: function () { return internal_ts_1.isUnionType; } });
|
|
60
|
-
Object.defineProperty(exports, "isValidReference", { enumerable: true, get: function () { return internal_ts_1.isValidReference; } });
|
|
61
|
-
Object.defineProperty(exports, "joinJsonPath", { enumerable: true, get: function () { return internal_ts_1.joinJsonPath; } });
|
|
62
|
-
Object.defineProperty(exports, "onAction", { enumerable: true, get: function () { return internal_ts_1.onAction; } });
|
|
63
|
-
Object.defineProperty(exports, "onPatch", { enumerable: true, get: function () { return internal_ts_1.onPatch; } });
|
|
64
|
-
Object.defineProperty(exports, "onSnapshot", { enumerable: true, get: function () { return internal_ts_1.onSnapshot; } });
|
|
65
|
-
Object.defineProperty(exports, "process", { enumerable: true, get: function () { return internal_ts_1.process; } });
|
|
66
|
-
Object.defineProperty(exports, "protect", { enumerable: true, get: function () { return internal_ts_1.protect; } });
|
|
67
|
-
Object.defineProperty(exports, "recordActions", { enumerable: true, get: function () { return internal_ts_1.recordActions; } });
|
|
68
|
-
Object.defineProperty(exports, "recordPatches", { enumerable: true, get: function () { return internal_ts_1.recordPatches; } });
|
|
69
|
-
Object.defineProperty(exports, "resolveIdentifier", { enumerable: true, get: function () { return internal_ts_1.resolveIdentifier; } });
|
|
70
|
-
Object.defineProperty(exports, "resolvePath", { enumerable: true, get: function () { return internal_ts_1.resolvePath; } });
|
|
71
|
-
Object.defineProperty(exports, "setLivelinessChecking", { enumerable: true, get: function () { return internal_ts_1.setLivelinessChecking; } });
|
|
72
|
-
Object.defineProperty(exports, "setLivelynessChecking", { enumerable: true, get: function () { return internal_ts_1.setLivelynessChecking; } });
|
|
73
|
-
Object.defineProperty(exports, "splitJsonPath", { enumerable: true, get: function () { return internal_ts_1.splitJsonPath; } });
|
|
74
|
-
Object.defineProperty(exports, "toGenerator", { enumerable: true, get: function () { return internal_ts_1.toGenerator; } });
|
|
75
|
-
Object.defineProperty(exports, "toGeneratorFunction", { enumerable: true, get: function () { return internal_ts_1.toGeneratorFunction; } });
|
|
76
|
-
Object.defineProperty(exports, "tryReference", { enumerable: true, get: function () { return internal_ts_1.tryReference; } });
|
|
77
|
-
Object.defineProperty(exports, "tryResolve", { enumerable: true, get: function () { return internal_ts_1.tryResolve; } });
|
|
78
|
-
Object.defineProperty(exports, "typecheck", { enumerable: true, get: function () { return internal_ts_1.typecheck; } });
|
|
79
|
-
Object.defineProperty(exports, "types", { enumerable: true, get: function () { return internal_ts_1.types; } });
|
|
80
|
-
Object.defineProperty(exports, "t", { enumerable: true, get: function () { return internal_ts_1.types; } });
|
|
81
|
-
Object.defineProperty(exports, "unescapeJsonPath", { enumerable: true, get: function () { return internal_ts_1.unescapeJsonPath; } });
|
|
82
|
-
Object.defineProperty(exports, "unprotect", { enumerable: true, get: function () { return internal_ts_1.unprotect; } });
|
|
83
|
-
Object.defineProperty(exports, "walk", { enumerable: true, get: function () { return internal_ts_1.walk; } });
|
|
84
|
-
Object.defineProperty(exports, "setDevMode", { enumerable: true, get: function () { return internal_ts_1.setDevMode; } });
|
|
85
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AA6EA,6CAgFsB;AA/EpB,0GAAA,WAAW,OAAA;AACX,4GAAA,aAAa,OAAA;AACb,0GAAA,WAAW,OAAA;AACX,yGAAA,UAAU,OAAA;AACV,4GAAA,aAAa,OAAA;AACb,mGAAA,IAAI,OAAA;AACJ,6GAAA,cAAc,OAAA;AACd,sHAAA,uBAAuB,OAAA;AACvB,6GAAA,cAAc,OAAA;AACd,oGAAA,KAAK,OAAA;AACL,8HAAA,+BAA+B,OAAA;AAC/B,6HAAA,8BAA8B,OAAA;AAC9B,uGAAA,QAAQ,OAAA;AACR,sGAAA,OAAO,OAAA;AACP,qGAAA,MAAM,OAAA;AACN,6GAAA,cAAc,OAAA;AACd,mGAAA,IAAI,OAAA;AACJ,2GAAA,YAAY,OAAA;AACZ,qGAAA,MAAM,OAAA;AACN,4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AAW,OAAA;AACX,kHAAA,mBAAmB,OAAA;AACnB,2GAAA,YAAY,OAAA;AACZ,yGAAA,UAAU,OAAA;AACV,wGAAA,SAAS,OAAA;AACT,oGAAA,KAAK,OAAA;AACL,gGAAA,KAAK,OAAK;AACV,+GAAA,gBAAgB,OAAA;AAChB,wGAAA,SAAS,OAAA;AACT,mGAAA,IAAI,OAAA;AACJ,yGAAA,UAAU,OAAA","sourcesContent":["/* all code is initially loaded through internal, to avoid circular dep issues */\nexport type {\n CustomTypeOptions,\n IActionContext,\n IActionRecorder,\n IActionTrackingMiddleware2Call,\n IActionTrackingMiddleware2Hooks,\n IActionTrackingMiddlewareHooks,\n IAnyComplexType,\n IAnyModelType,\n IAnyStateTreeNode,\n IAnyType,\n IArrayType,\n IComplexType,\n IDisposer,\n IJsonPatch,\n IMSTArray,\n IMSTMap,\n IMapType,\n IMaybe,\n IMaybeIType,\n IMaybeNull,\n IMiddlewareEvent,\n IMiddlewareEventType,\n IMiddlewareHandler,\n IModelReflectionData,\n IModelReflectionPropertiesData,\n IModelType,\n IOptionalIType,\n IPatchRecorder,\n IReferenceType,\n IReversibleJsonPatch,\n ISerializedActionCall,\n ISimpleType,\n ISnapshotProcessor,\n ISnapshotProcessors,\n IStateTreeNode,\n IType,\n ITypeUnion,\n Instance,\n LivelinessMode,\n LivelynessMode,\n ModelActions,\n ModelCreationType2,\n ModelCreationType,\n ModelInstanceType,\n ModelInstanceTypeProps,\n ModelPrimitive,\n ModelProperties,\n ModelPropertiesDeclaration,\n ModelPropertiesDeclarationToProperties,\n ModelSnapshotType2,\n ModelSnapshotType,\n OnReferenceInvalidated,\n OnReferenceInvalidatedEvent,\n OptionalDefaultValueOrFunction,\n ReferenceIdentifier,\n ReferenceOptions,\n ReferenceOptionsGetSet,\n ReferenceOptionsOnInvalidated,\n SnapshotIn,\n SnapshotOrInstance,\n SnapshotOut,\n TypeOfValue,\n TypeOrStateTreeNodeToStateTreeNode,\n UnionOptions,\n UnionStringArray,\n ValidOptionalValue,\n ValidOptionalValues,\n _CustomCSProcessor,\n _CustomJoin,\n _CustomOrOther,\n _NotCustomized,\n NonEmptyObject,\n ExtractCFromProps\n} from \"./internal.ts\"\n\nexport {\n addDisposer,\n addMiddleware,\n applyAction,\n applyPatch,\n applySnapshot,\n cast,\n castFlowReturn,\n castToReferenceSnapshot,\n castToSnapshot,\n clone,\n createActionTrackingMiddleware2,\n createActionTrackingMiddleware,\n decorate,\n destroy,\n detach,\n escapeJsonPath,\n flow,\n getChildType,\n getEnv,\n getIdentifier,\n getLivelinessChecking,\n getMembers,\n getNodeId,\n getParent,\n getParentOfType,\n getPath,\n getPathParts,\n getPropertyMembers,\n getRelativePath,\n getRoot,\n getRunningActionContext,\n getSnapshot,\n getType,\n hasParent,\n hasParentOfType,\n isActionContextChildOf,\n isActionContextThisOrChildOf,\n isAlive,\n isArrayType,\n isFrozenType,\n isIdentifierType,\n isLateType,\n isLiteralType,\n isMapType,\n isModelType,\n isOptionalType,\n isPrimitiveType,\n isProtected,\n isReferenceType,\n isRefinementType,\n isRoot,\n isStateTreeNode,\n isType,\n isUnionType,\n isValidReference,\n joinJsonPath,\n onAction,\n onPatch,\n onSnapshot,\n process,\n protect,\n recordActions,\n recordPatches,\n resolveIdentifier,\n resolvePath,\n setLivelinessChecking,\n setLivelynessChecking,\n splitJsonPath,\n toGenerator,\n toGeneratorFunction,\n tryReference,\n tryResolve,\n typecheck,\n types,\n types as t,\n unescapeJsonPath,\n unprotect,\n walk,\n setDevMode\n} from \"./internal.ts\"\n"]}
|
package/dist/internal.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
export * from "./core/node/livelinessChecking.ts";
|
|
2
|
-
export * from "./core/node/Hook.ts";
|
|
3
|
-
export * from "./core/mst-operations.ts";
|
|
4
|
-
export * from "./core/node/BaseNode.ts";
|
|
5
|
-
export * from "./core/node/scalar-node.ts";
|
|
6
|
-
export * from "./core/node/object-node.ts";
|
|
7
|
-
export * from "./core/type/type.ts";
|
|
8
|
-
export * from "./middlewares/create-action-tracking-middleware.ts";
|
|
9
|
-
export * from "./middlewares/createActionTrackingMiddleware2.ts";
|
|
10
|
-
export * from "./middlewares/on-action.ts";
|
|
11
|
-
export * from "./core/action.ts";
|
|
12
|
-
export * from "./core/actionContext.ts";
|
|
13
|
-
export * from "./core/type/type-checker.ts";
|
|
14
|
-
export * from "./core/node/identifier-cache.ts";
|
|
15
|
-
export * from "./core/node/create-node.ts";
|
|
16
|
-
export * from "./core/node/node-utils.ts";
|
|
17
|
-
export * from "./core/process.ts";
|
|
18
|
-
export * from "./core/flow.ts";
|
|
19
|
-
export * from "./core/json-patch.ts";
|
|
20
|
-
export * from "./utils.ts";
|
|
21
|
-
export * from "./types/utility-types/snapshotProcessor.ts";
|
|
22
|
-
export * from "./types/complex-types/map.ts";
|
|
23
|
-
export * from "./types/complex-types/array.ts";
|
|
24
|
-
export * from "./types/complex-types/model.ts";
|
|
25
|
-
export * from "./types/primitives.ts";
|
|
26
|
-
export * from "./types/utility-types/literal.ts";
|
|
27
|
-
export * from "./types/utility-types/refinement.ts";
|
|
28
|
-
export * from "./types/utility-types/enumeration.ts";
|
|
29
|
-
export * from "./types/utility-types/union.ts";
|
|
30
|
-
export * from "./types/utility-types/optional.ts";
|
|
31
|
-
export * from "./types/utility-types/maybe.ts";
|
|
32
|
-
export * from "./types/utility-types/late.ts";
|
|
33
|
-
export * from "./types/utility-types/lazy.ts";
|
|
34
|
-
export * from "./types/utility-types/frozen.ts";
|
|
35
|
-
export * from "./types/utility-types/reference.ts";
|
|
36
|
-
export * from "./types/utility-types/identifier.ts";
|
|
37
|
-
export * from "./types/utility-types/custom.ts";
|
|
38
|
-
export * from "./types/utility-types/resilient.ts";
|
|
39
|
-
export * from "./types/index.ts";
|
package/dist/internal.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* All imports / exports should be proxied through this file.
|
|
4
|
-
* Why? It gives us full control over the module load order, preventing circular dependency isses
|
|
5
|
-
*/
|
|
6
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
-
if (k2 === undefined) k2 = k;
|
|
8
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
-
}
|
|
12
|
-
Object.defineProperty(o, k2, desc);
|
|
13
|
-
}) : (function(o, m, k, k2) {
|
|
14
|
-
if (k2 === undefined) k2 = k;
|
|
15
|
-
o[k2] = m[k];
|
|
16
|
-
}));
|
|
17
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
18
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
__exportStar(require("./core/node/livelinessChecking.js"), exports);
|
|
22
|
-
__exportStar(require("./core/node/Hook.js"), exports);
|
|
23
|
-
__exportStar(require("./core/mst-operations.js"), exports);
|
|
24
|
-
__exportStar(require("./core/node/BaseNode.js"), exports);
|
|
25
|
-
__exportStar(require("./core/node/scalar-node.js"), exports);
|
|
26
|
-
__exportStar(require("./core/node/object-node.js"), exports);
|
|
27
|
-
__exportStar(require("./core/type/type.js"), exports);
|
|
28
|
-
__exportStar(require("./middlewares/create-action-tracking-middleware.js"), exports);
|
|
29
|
-
__exportStar(require("./middlewares/createActionTrackingMiddleware2.js"), exports);
|
|
30
|
-
__exportStar(require("./middlewares/on-action.js"), exports);
|
|
31
|
-
__exportStar(require("./core/action.js"), exports);
|
|
32
|
-
__exportStar(require("./core/actionContext.js"), exports);
|
|
33
|
-
__exportStar(require("./core/type/type-checker.js"), exports);
|
|
34
|
-
__exportStar(require("./core/node/identifier-cache.js"), exports);
|
|
35
|
-
__exportStar(require("./core/node/create-node.js"), exports);
|
|
36
|
-
__exportStar(require("./core/node/node-utils.js"), exports);
|
|
37
|
-
__exportStar(require("./core/process.js"), exports);
|
|
38
|
-
__exportStar(require("./core/flow.js"), exports);
|
|
39
|
-
__exportStar(require("./core/json-patch.js"), exports);
|
|
40
|
-
__exportStar(require("./utils.js"), exports);
|
|
41
|
-
__exportStar(require("./types/utility-types/snapshotProcessor.js"), exports);
|
|
42
|
-
__exportStar(require("./types/complex-types/map.js"), exports);
|
|
43
|
-
__exportStar(require("./types/complex-types/array.js"), exports);
|
|
44
|
-
__exportStar(require("./types/complex-types/model.js"), exports);
|
|
45
|
-
__exportStar(require("./types/primitives.js"), exports);
|
|
46
|
-
__exportStar(require("./types/utility-types/literal.js"), exports);
|
|
47
|
-
__exportStar(require("./types/utility-types/refinement.js"), exports);
|
|
48
|
-
__exportStar(require("./types/utility-types/enumeration.js"), exports);
|
|
49
|
-
__exportStar(require("./types/utility-types/union.js"), exports);
|
|
50
|
-
__exportStar(require("./types/utility-types/optional.js"), exports);
|
|
51
|
-
__exportStar(require("./types/utility-types/maybe.js"), exports);
|
|
52
|
-
__exportStar(require("./types/utility-types/late.js"), exports);
|
|
53
|
-
__exportStar(require("./types/utility-types/lazy.js"), exports);
|
|
54
|
-
__exportStar(require("./types/utility-types/frozen.js"), exports);
|
|
55
|
-
__exportStar(require("./types/utility-types/reference.js"), exports);
|
|
56
|
-
__exportStar(require("./types/utility-types/identifier.js"), exports);
|
|
57
|
-
__exportStar(require("./types/utility-types/custom.js"), exports);
|
|
58
|
-
__exportStar(require("./types/utility-types/resilient.js"), exports);
|
|
59
|
-
__exportStar(require("./types/index.js"), exports);
|
|
60
|
-
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;AAEH,oEAAiD;AACjD,sDAAmC;AACnC,2DAAwC;AACxC,0DAAuC;AACvC,6DAA0C;AAC1C,6DAA0C;AAC1C,sDAAmC;AACnC,qFAAkE;AAClE,mFAAgE;AAChE,6DAA0C;AAC1C,mDAAgC;AAChC,0DAAuC;AACvC,8DAA2C;AAC3C,kEAA+C;AAC/C,6DAA0C;AAC1C,4DAAyC;AACzC,oDAAiC;AACjC,iDAA8B;AAC9B,uDAAoC;AACpC,6CAA0B;AAC1B,6EAA0D;AAC1D,+DAA4C;AAC5C,iEAA8C;AAC9C,iEAA8C;AAC9C,wDAAqC;AACrC,mEAAgD;AAChD,sEAAmD;AACnD,uEAAoD;AACpD,iEAA8C;AAC9C,oEAAiD;AACjD,iEAA8C;AAC9C,gEAA6C;AAC7C,gEAA6C;AAC7C,kEAA+C;AAC/C,qEAAkD;AAClD,sEAAmD;AACnD,kEAA+C;AAC/C,qEAAkD;AAClD,mDAAgC","sourcesContent":["/*\n * All imports / exports should be proxied through this file.\n * Why? It gives us full control over the module load order, preventing circular dependency isses\n */\n\nexport * from \"./core/node/livelinessChecking.ts\"\nexport * from \"./core/node/Hook.ts\"\nexport * from \"./core/mst-operations.ts\"\nexport * from \"./core/node/BaseNode.ts\"\nexport * from \"./core/node/scalar-node.ts\"\nexport * from \"./core/node/object-node.ts\"\nexport * from \"./core/type/type.ts\"\nexport * from \"./middlewares/create-action-tracking-middleware.ts\"\nexport * from \"./middlewares/createActionTrackingMiddleware2.ts\"\nexport * from \"./middlewares/on-action.ts\"\nexport * from \"./core/action.ts\"\nexport * from \"./core/actionContext.ts\"\nexport * from \"./core/type/type-checker.ts\"\nexport * from \"./core/node/identifier-cache.ts\"\nexport * from \"./core/node/create-node.ts\"\nexport * from \"./core/node/node-utils.ts\"\nexport * from \"./core/process.ts\"\nexport * from \"./core/flow.ts\"\nexport * from \"./core/json-patch.ts\"\nexport * from \"./utils.ts\"\nexport * from \"./types/utility-types/snapshotProcessor.ts\"\nexport * from \"./types/complex-types/map.ts\"\nexport * from \"./types/complex-types/array.ts\"\nexport * from \"./types/complex-types/model.ts\"\nexport * from \"./types/primitives.ts\"\nexport * from \"./types/utility-types/literal.ts\"\nexport * from \"./types/utility-types/refinement.ts\"\nexport * from \"./types/utility-types/enumeration.ts\"\nexport * from \"./types/utility-types/union.ts\"\nexport * from \"./types/utility-types/optional.ts\"\nexport * from \"./types/utility-types/maybe.ts\"\nexport * from \"./types/utility-types/late.ts\"\nexport * from \"./types/utility-types/lazy.ts\"\nexport * from \"./types/utility-types/frozen.ts\"\nexport * from \"./types/utility-types/reference.ts\"\nexport * from \"./types/utility-types/identifier.ts\"\nexport * from \"./types/utility-types/custom.ts\"\nexport * from \"./types/utility-types/resilient.ts\"\nexport * from \"./types/index.ts\"\n"]}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { type IMiddlewareEvent, type IMiddlewareHandler } from "../internal.ts";
|
|
2
|
-
export interface IActionTrackingMiddlewareHooks<T> {
|
|
3
|
-
filter?: (call: IMiddlewareEvent) => boolean;
|
|
4
|
-
onStart: (call: IMiddlewareEvent) => T;
|
|
5
|
-
onResume: (call: IMiddlewareEvent, context: T) => void;
|
|
6
|
-
onSuspend: (call: IMiddlewareEvent, context: T) => void;
|
|
7
|
-
onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void;
|
|
8
|
-
onFail: (call: IMiddlewareEvent, context: T, error: any) => void;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.
|
|
12
|
-
*
|
|
13
|
-
* Convenience utility to create action based middleware that supports async processes more easily.
|
|
14
|
-
* All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called
|
|
15
|
-
*
|
|
16
|
-
* The create middleware tracks the process of an action (assuming it passes the `filter`).
|
|
17
|
-
* `onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.
|
|
18
|
-
*
|
|
19
|
-
* See the `atomic` middleware for an example
|
|
20
|
-
*
|
|
21
|
-
* @param hooks
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
export declare function createActionTrackingMiddleware<T = any>(hooks: IActionTrackingMiddlewareHooks<T>): IMiddlewareHandler;
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createActionTrackingMiddleware = createActionTrackingMiddleware;
|
|
4
|
-
const runningActions = new Map();
|
|
5
|
-
/**
|
|
6
|
-
* Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.
|
|
7
|
-
*
|
|
8
|
-
* Convenience utility to create action based middleware that supports async processes more easily.
|
|
9
|
-
* All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called
|
|
10
|
-
*
|
|
11
|
-
* The create middleware tracks the process of an action (assuming it passes the `filter`).
|
|
12
|
-
* `onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.
|
|
13
|
-
*
|
|
14
|
-
* See the `atomic` middleware for an example
|
|
15
|
-
*
|
|
16
|
-
* @param hooks
|
|
17
|
-
* @returns
|
|
18
|
-
*/
|
|
19
|
-
function createActionTrackingMiddleware(hooks) {
|
|
20
|
-
return function actionTrackingMiddleware(call, next, _abort) {
|
|
21
|
-
switch (call.type) {
|
|
22
|
-
case "action": {
|
|
23
|
-
if (!hooks.filter || hooks.filter(call) === true) {
|
|
24
|
-
const context = hooks.onStart(call);
|
|
25
|
-
hooks.onResume(call, context);
|
|
26
|
-
runningActions.set(call.id, {
|
|
27
|
-
call,
|
|
28
|
-
context,
|
|
29
|
-
async: false
|
|
30
|
-
});
|
|
31
|
-
try {
|
|
32
|
-
const res = next(call);
|
|
33
|
-
hooks.onSuspend(call, context);
|
|
34
|
-
if (runningActions.get(call.id).async === false) {
|
|
35
|
-
runningActions.delete(call.id);
|
|
36
|
-
hooks.onSuccess(call, context, res);
|
|
37
|
-
}
|
|
38
|
-
return res;
|
|
39
|
-
}
|
|
40
|
-
catch (e) {
|
|
41
|
-
runningActions.delete(call.id);
|
|
42
|
-
hooks.onFail(call, context, e);
|
|
43
|
-
throw e;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
return next(call);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
case "flow_spawn": {
|
|
51
|
-
const root = runningActions.get(call.rootId);
|
|
52
|
-
root.async = true;
|
|
53
|
-
return next(call);
|
|
54
|
-
}
|
|
55
|
-
case "flow_resume":
|
|
56
|
-
case "flow_resume_error": {
|
|
57
|
-
const root = runningActions.get(call.rootId);
|
|
58
|
-
hooks.onResume(call, root.context);
|
|
59
|
-
try {
|
|
60
|
-
return next(call);
|
|
61
|
-
}
|
|
62
|
-
finally {
|
|
63
|
-
hooks.onSuspend(call, root.context);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
case "flow_throw": {
|
|
67
|
-
const root = runningActions.get(call.rootId);
|
|
68
|
-
runningActions.delete(call.rootId);
|
|
69
|
-
hooks.onFail(call, root.context, call.args[0]);
|
|
70
|
-
return next(call);
|
|
71
|
-
}
|
|
72
|
-
case "flow_return": {
|
|
73
|
-
const root = runningActions.get(call.rootId);
|
|
74
|
-
runningActions.delete(call.rootId);
|
|
75
|
-
hooks.onSuccess(call, root.context, call.args[0]);
|
|
76
|
-
return next(call);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=create-action-tracking-middleware.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-action-tracking-middleware.js","sourceRoot":"","sources":["../../src/middlewares/create-action-tracking-middleware.ts"],"names":[],"mappings":";;AA8BA,wEAgEC;AA5FD,MAAM,cAAc,GAAG,IAAI,GAAG,EAG3B,CAAA;AAWH;;;;;;;;;;;;;GAaG;AACH,SAAgB,8BAA8B,CAC5C,KAAwC;IAExC,OAAO,SAAS,wBAAwB,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,IAAI,CAAC,IAAI,CAAC,CAAA;YACnB,CAAC;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { type IMiddlewareEvent, type IMiddlewareHandler } from \"../internal.ts\"\n\nconst runningActions = new Map<\n number,\n { async: boolean; call: IMiddlewareEvent; context: any }\n>()\n\nexport interface IActionTrackingMiddlewareHooks<T> {\n filter?: (call: IMiddlewareEvent) => boolean\n onStart: (call: IMiddlewareEvent) => T\n onResume: (call: IMiddlewareEvent, context: T) => void\n onSuspend: (call: IMiddlewareEvent, context: T) => void\n onSuccess: (call: IMiddlewareEvent, context: T, result: any) => void\n onFail: (call: IMiddlewareEvent, context: T, error: any) => void\n}\n\n/**\n * Note: Consider migrating to `createActionTrackingMiddleware2`, it is easier to use.\n *\n * Convenience utility to create action based middleware that supports async processes more easily.\n * All hooks are called for both synchronous and asynchronous actions. Except that either `onSuccess` or `onFail` is called\n *\n * The create middleware tracks the process of an action (assuming it passes the `filter`).\n * `onResume` can return any value, which will be passed as second argument to any other hook. This makes it possible to keep state during a process.\n *\n * See the `atomic` middleware for an example\n *\n * @param hooks\n * @returns\n */\nexport function createActionTrackingMiddleware<T = any>(\n hooks: IActionTrackingMiddlewareHooks<T>\n): IMiddlewareHandler {\n return function actionTrackingMiddleware(\n call: IMiddlewareEvent,\n next: (actionCall: IMiddlewareEvent) => any,\n _abort: (value: any) => any\n ) {\n switch (call.type) {\n case \"action\": {\n if (!hooks.filter || hooks.filter(call) === true) {\n const context = hooks.onStart(call)\n hooks.onResume(call, context)\n runningActions.set(call.id, {\n call,\n context,\n async: false\n })\n try {\n const res = next(call)\n hooks.onSuspend(call, context)\n if (runningActions.get(call.id)!.async === false) {\n runningActions.delete(call.id)\n hooks.onSuccess(call, context, res)\n }\n return res\n } catch (e) {\n runningActions.delete(call.id)\n hooks.onFail(call, context, e)\n throw e\n }\n } else {\n return next(call)\n }\n }\n case \"flow_spawn\": {\n const root = runningActions.get(call.rootId)!\n root.async = true\n return next(call)\n }\n case \"flow_resume\":\n case \"flow_resume_error\": {\n const root = runningActions.get(call.rootId)!\n hooks.onResume(call, root.context)\n try {\n return next(call)\n } finally {\n hooks.onSuspend(call, root.context)\n }\n }\n case \"flow_throw\": {\n const root = runningActions.get(call.rootId)!\n runningActions.delete(call.rootId)\n hooks.onFail(call, root.context, call.args[0])\n return next(call)\n }\n case \"flow_return\": {\n const root = runningActions.get(call.rootId)!\n runningActions.delete(call.rootId)\n hooks.onSuccess(call, root.context, call.args[0])\n return next(call)\n }\n }\n }\n}\n"]}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type IActionContext, type IMiddlewareHandler } from "../internal.ts";
|
|
2
|
-
export interface IActionTrackingMiddleware2Call<TEnv> extends Readonly<IActionContext> {
|
|
3
|
-
env: TEnv | undefined;
|
|
4
|
-
readonly parentCall?: IActionTrackingMiddleware2Call<TEnv>;
|
|
5
|
-
}
|
|
6
|
-
export interface IActionTrackingMiddleware2Hooks<TEnv> {
|
|
7
|
-
filter?: (call: IActionTrackingMiddleware2Call<TEnv>) => boolean;
|
|
8
|
-
onStart: (call: IActionTrackingMiddleware2Call<TEnv>) => void;
|
|
9
|
-
onFinish: (call: IActionTrackingMiddleware2Call<TEnv>, error?: any) => void;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Convenience utility to create action based middleware that supports async processes more easily.
|
|
13
|
-
* The flow is like this:
|
|
14
|
-
* - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`
|
|
15
|
-
*
|
|
16
|
-
* Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:
|
|
17
|
-
* - `filter(a)`
|
|
18
|
-
* - `onStart(a)`
|
|
19
|
-
* - `filter(b1)`
|
|
20
|
-
* - `onStart(b1)`
|
|
21
|
-
* - `onFinish(b1)`
|
|
22
|
-
* - `filter(b2)`
|
|
23
|
-
* - `onStart(b2)`
|
|
24
|
-
* - `onFinish(b2)`
|
|
25
|
-
* - `onFinish(a)`
|
|
26
|
-
*
|
|
27
|
-
* The flow is the same no matter if the actions are sync or async.
|
|
28
|
-
*
|
|
29
|
-
* See the `atomic` middleware for an example
|
|
30
|
-
*
|
|
31
|
-
* @param hooks
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
export declare function createActionTrackingMiddleware2<TEnv = any>(middlewareHooks: IActionTrackingMiddleware2Hooks<TEnv>): IMiddlewareHandler;
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createActionTrackingMiddleware2 = createActionTrackingMiddleware2;
|
|
4
|
-
class RunningAction {
|
|
5
|
-
hooks;
|
|
6
|
-
call;
|
|
7
|
-
flowsPending = 0;
|
|
8
|
-
running = true;
|
|
9
|
-
constructor(hooks, call) {
|
|
10
|
-
this.hooks = hooks;
|
|
11
|
-
this.call = call;
|
|
12
|
-
if (hooks) {
|
|
13
|
-
hooks.onStart(call);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
finish(error) {
|
|
17
|
-
if (this.running) {
|
|
18
|
-
this.running = false;
|
|
19
|
-
if (this.hooks) {
|
|
20
|
-
this.hooks.onFinish(this.call, error);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
incFlowsPending() {
|
|
25
|
-
this.flowsPending++;
|
|
26
|
-
}
|
|
27
|
-
decFlowsPending() {
|
|
28
|
-
this.flowsPending--;
|
|
29
|
-
}
|
|
30
|
-
get hasFlowsPending() {
|
|
31
|
-
return this.flowsPending > 0;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Convenience utility to create action based middleware that supports async processes more easily.
|
|
36
|
-
* The flow is like this:
|
|
37
|
-
* - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`
|
|
38
|
-
*
|
|
39
|
-
* Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:
|
|
40
|
-
* - `filter(a)`
|
|
41
|
-
* - `onStart(a)`
|
|
42
|
-
* - `filter(b1)`
|
|
43
|
-
* - `onStart(b1)`
|
|
44
|
-
* - `onFinish(b1)`
|
|
45
|
-
* - `filter(b2)`
|
|
46
|
-
* - `onStart(b2)`
|
|
47
|
-
* - `onFinish(b2)`
|
|
48
|
-
* - `onFinish(a)`
|
|
49
|
-
*
|
|
50
|
-
* The flow is the same no matter if the actions are sync or async.
|
|
51
|
-
*
|
|
52
|
-
* See the `atomic` middleware for an example
|
|
53
|
-
*
|
|
54
|
-
* @param hooks
|
|
55
|
-
* @returns
|
|
56
|
-
*/
|
|
57
|
-
function createActionTrackingMiddleware2(middlewareHooks) {
|
|
58
|
-
const runningActions = new Map();
|
|
59
|
-
return function actionTrackingMiddleware(call, next) {
|
|
60
|
-
// find parentRunningAction
|
|
61
|
-
const parentRunningAction = call.parentActionEvent
|
|
62
|
-
? runningActions.get(call.parentActionEvent.id)
|
|
63
|
-
: undefined;
|
|
64
|
-
if (call.type === "action") {
|
|
65
|
-
const newCall = {
|
|
66
|
-
...call,
|
|
67
|
-
// make a shallow copy of the parent action env
|
|
68
|
-
env: parentRunningAction && parentRunningAction.call.env,
|
|
69
|
-
parentCall: parentRunningAction && parentRunningAction.call
|
|
70
|
-
};
|
|
71
|
-
const passesFilter = !middlewareHooks.filter || middlewareHooks.filter(newCall);
|
|
72
|
-
const hooks = passesFilter ? middlewareHooks : undefined;
|
|
73
|
-
const runningAction = new RunningAction(hooks, newCall);
|
|
74
|
-
runningActions.set(call.id, runningAction);
|
|
75
|
-
let res;
|
|
76
|
-
try {
|
|
77
|
-
res = next(call);
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
runningActions.delete(call.id);
|
|
81
|
-
runningAction.finish(e);
|
|
82
|
-
throw e;
|
|
83
|
-
}
|
|
84
|
-
// sync action finished
|
|
85
|
-
if (!runningAction.hasFlowsPending) {
|
|
86
|
-
runningActions.delete(call.id);
|
|
87
|
-
runningAction.finish();
|
|
88
|
-
}
|
|
89
|
-
return res;
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
if (!parentRunningAction) {
|
|
93
|
-
return next(call);
|
|
94
|
-
}
|
|
95
|
-
switch (call.type) {
|
|
96
|
-
case "flow_spawn": {
|
|
97
|
-
parentRunningAction.incFlowsPending();
|
|
98
|
-
return next(call);
|
|
99
|
-
}
|
|
100
|
-
case "flow_resume":
|
|
101
|
-
case "flow_resume_error": {
|
|
102
|
-
return next(call);
|
|
103
|
-
}
|
|
104
|
-
case "flow_throw": {
|
|
105
|
-
const error = call.args[0];
|
|
106
|
-
try {
|
|
107
|
-
return next(call);
|
|
108
|
-
}
|
|
109
|
-
finally {
|
|
110
|
-
parentRunningAction.decFlowsPending();
|
|
111
|
-
if (!parentRunningAction.hasFlowsPending) {
|
|
112
|
-
runningActions.delete(call.parentActionEvent.id);
|
|
113
|
-
parentRunningAction.finish(error);
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
case "flow_return": {
|
|
118
|
-
try {
|
|
119
|
-
return next(call);
|
|
120
|
-
}
|
|
121
|
-
finally {
|
|
122
|
-
parentRunningAction.decFlowsPending();
|
|
123
|
-
if (!parentRunningAction.hasFlowsPending) {
|
|
124
|
-
runningActions.delete(call.parentActionEvent.id);
|
|
125
|
-
parentRunningAction.finish();
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
}
|
|
133
|
-
//# sourceMappingURL=createActionTrackingMiddleware2.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"createActionTrackingMiddleware2.js","sourceRoot":"","sources":["../../src/middlewares/createActionTrackingMiddleware2.ts"],"names":[],"mappings":";;AA6EA,0EAmFC;AA7ID,MAAM,aAAa;IAKC;IACP;IALH,YAAY,GAAG,CAAC,CAAA;IAChB,OAAO,GAAG,IAAI,CAAA;IA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A;gBACnB,CAAC;gBACD,KAAK,YAAY,CAAC,CAAC,CAAC;oBAClB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;oBAC1B,IAAI,CAAC;wBACH,OAAO,IAAI,CAAC,IAAI,CAAC,CAAA;oBACnB,CAAC;4BAAS,CAAC;wBACT,mBAAmB,CAAC,eAAe,EAAE,CAAA;wBACrC,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC;4BACzC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAkB,CAAC,EAAE,CAAC,CAAA;4BACjD,mBAAmB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;wBACnC,CAAC;oBACH,CAAC;gBACH,CAAC;gBACD,KAAK,aAAa,CAAC,CAAC,CAAC;oBACnB,IAAI,CAAC;wBACH,OAAO,IAAI,CAAC,IAAI,CAAC,CAAA;oBACnB,CAAC;4BAAS,CAAC;wBACT,mBAAmB,CAAC,eAAe,EAAE,CAAA;wBACrC,IAAI,CAAC,mBAAmB,CAAC,eAAe,EAAE,CAAC;4BACzC,cAAc,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAkB,CAAC,EAAE,CAAC,CAAA;4BACjD,mBAAmB,CAAC,MAAM,EAAE,CAAA;wBAC9B,CAAC;oBACH,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC,CAAA;AACH,CAAC","sourcesContent":["import {\n type IActionContext,\n type IMiddlewareEvent,\n type IMiddlewareHandler\n} from \"../internal.ts\"\n\nexport interface IActionTrackingMiddleware2Call<\n TEnv\n> extends Readonly<IActionContext> {\n env: TEnv | undefined\n readonly parentCall?: IActionTrackingMiddleware2Call<TEnv>\n}\n\nexport interface IActionTrackingMiddleware2Hooks<TEnv> {\n filter?: (call: IActionTrackingMiddleware2Call<TEnv>) => boolean\n onStart: (call: IActionTrackingMiddleware2Call<TEnv>) => void\n onFinish: (call: IActionTrackingMiddleware2Call<TEnv>, error?: any) => void\n}\n\nclass RunningAction {\n private flowsPending = 0\n private running = true\n\n constructor(\n public readonly hooks: IActionTrackingMiddleware2Hooks<any> | undefined,\n readonly call: IActionTrackingMiddleware2Call<any>\n ) {\n if (hooks) {\n hooks.onStart(call)\n }\n }\n\n finish(error?: any) {\n if (this.running) {\n this.running = false\n if (this.hooks) {\n this.hooks.onFinish(this.call, error)\n }\n }\n }\n\n incFlowsPending() {\n this.flowsPending++\n }\n\n decFlowsPending() {\n this.flowsPending--\n }\n\n get hasFlowsPending() {\n return this.flowsPending > 0\n }\n}\n\n/**\n * Convenience utility to create action based middleware that supports async processes more easily.\n * The flow is like this:\n * - for each action: if filter passes -> `onStart` -> (inner actions recursively) -> `onFinish`\n *\n * Example: if we had an action `a` that called inside an action `b1`, then `b2` the flow would be:\n * - `filter(a)`\n * - `onStart(a)`\n * - `filter(b1)`\n * - `onStart(b1)`\n * - `onFinish(b1)`\n * - `filter(b2)`\n * - `onStart(b2)`\n * - `onFinish(b2)`\n * - `onFinish(a)`\n *\n * The flow is the same no matter if the actions are sync or async.\n *\n * See the `atomic` middleware for an example\n *\n * @param hooks\n * @returns\n */\nexport function createActionTrackingMiddleware2<TEnv = any>(\n middlewareHooks: IActionTrackingMiddleware2Hooks<TEnv>\n): IMiddlewareHandler {\n const runningActions = new Map<number, RunningAction>()\n\n return function actionTrackingMiddleware(\n call: IMiddlewareEvent,\n next: (actionCall: IMiddlewareEvent) => any\n ) {\n // find parentRunningAction\n const parentRunningAction = call.parentActionEvent\n ? runningActions.get(call.parentActionEvent.id)\n : undefined\n\n if (call.type === \"action\") {\n const newCall: IActionTrackingMiddleware2Call<TEnv> = {\n ...call,\n // make a shallow copy of the parent action env\n env: parentRunningAction && parentRunningAction.call.env,\n parentCall: parentRunningAction && parentRunningAction.call\n }\n\n const passesFilter =\n !middlewareHooks.filter || middlewareHooks.filter(newCall)\n const hooks = passesFilter ? middlewareHooks : undefined\n\n const runningAction = new RunningAction(hooks, newCall)\n runningActions.set(call.id, runningAction)\n\n let res\n try {\n res = next(call)\n } catch (e) {\n runningActions.delete(call.id)\n runningAction.finish(e)\n throw e\n }\n // sync action finished\n if (!runningAction.hasFlowsPending) {\n runningActions.delete(call.id)\n runningAction.finish()\n }\n return res\n } else {\n if (!parentRunningAction) {\n return next(call)\n }\n\n switch (call.type) {\n case \"flow_spawn\": {\n parentRunningAction.incFlowsPending()\n return next(call)\n }\n case \"flow_resume\":\n case \"flow_resume_error\": {\n return next(call)\n }\n case \"flow_throw\": {\n const error = call.args[0]\n try {\n return next(call)\n } finally {\n parentRunningAction.decFlowsPending()\n if (!parentRunningAction.hasFlowsPending) {\n runningActions.delete(call.parentActionEvent!.id)\n parentRunningAction.finish(error)\n }\n }\n }\n case \"flow_return\": {\n try {\n return next(call)\n } finally {\n parentRunningAction.decFlowsPending()\n if (!parentRunningAction.hasFlowsPending) {\n runningActions.delete(call.parentActionEvent!.id)\n parentRunningAction.finish()\n }\n }\n }\n }\n }\n }\n}\n"]}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { type IActionContext, type IAnyStateTreeNode, type IDisposer } from "../internal.ts";
|
|
2
|
-
export interface ISerializedActionCall {
|
|
3
|
-
name: string;
|
|
4
|
-
path?: string;
|
|
5
|
-
args?: any[];
|
|
6
|
-
}
|
|
7
|
-
export interface IActionRecorder {
|
|
8
|
-
actions: ReadonlyArray<ISerializedActionCall>;
|
|
9
|
-
readonly recording: boolean;
|
|
10
|
-
stop(): void;
|
|
11
|
-
resume(): void;
|
|
12
|
-
replay(target: IAnyStateTreeNode): void;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Applies an action or a series of actions in a single MobX transaction.
|
|
16
|
-
* Does not return any value
|
|
17
|
-
* Takes an action description as produced by the `onAction` middleware.
|
|
18
|
-
*
|
|
19
|
-
* @param target
|
|
20
|
-
* @param actions
|
|
21
|
-
*/
|
|
22
|
-
export declare function applyAction(target: IAnyStateTreeNode, actions: ISerializedActionCall | ISerializedActionCall[]): void;
|
|
23
|
-
/**
|
|
24
|
-
* Small abstraction around `onAction` and `applyAction`, attaches an action listener to a tree and records all the actions emitted.
|
|
25
|
-
* Returns an recorder object with the following signature:
|
|
26
|
-
*
|
|
27
|
-
* Example:
|
|
28
|
-
* ```ts
|
|
29
|
-
* export interface IActionRecorder {
|
|
30
|
-
* // the recorded actions
|
|
31
|
-
* actions: ISerializedActionCall[]
|
|
32
|
-
* // true if currently recording
|
|
33
|
-
* recording: boolean
|
|
34
|
-
* // stop recording actions
|
|
35
|
-
* stop(): void
|
|
36
|
-
* // resume recording actions
|
|
37
|
-
* resume(): void
|
|
38
|
-
* // apply all the recorded actions on the given object
|
|
39
|
-
* replay(target: IAnyStateTreeNode): void
|
|
40
|
-
* }
|
|
41
|
-
* ```
|
|
42
|
-
*
|
|
43
|
-
* The optional filter function allows to skip recording certain actions.
|
|
44
|
-
*
|
|
45
|
-
* @param subject
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
export declare function recordActions(subject: IAnyStateTreeNode, filter?: (action: ISerializedActionCall, actionContext: IActionContext | undefined) => boolean): IActionRecorder;
|
|
49
|
-
/**
|
|
50
|
-
* Registers a function that will be invoked for each action that is called on the provided model instance, or to any of its children.
|
|
51
|
-
* See [actions](https://github.com/mobxjs/mobx-state-tree#actions) for more details. onAction events are emitted only for the outermost called action in the stack.
|
|
52
|
-
* Action can also be intercepted by middleware using addMiddleware to change the function call before it will be run.
|
|
53
|
-
*
|
|
54
|
-
* Not all action arguments might be serializable. For unserializable arguments, a struct like `{ $MST_UNSERIALIZABLE: true, type: "someType" }` will be generated.
|
|
55
|
-
* MST Nodes are considered non-serializable as well (they could be serialized as there snapshot, but it is uncertain whether an replaying party will be able to handle such a non-instantiated snapshot).
|
|
56
|
-
* Rather, when using `onAction` middleware, one should consider in passing arguments which are 1: an id, 2: a (relative) path, or 3: a snapshot. Instead of a real MST node.
|
|
57
|
-
*
|
|
58
|
-
* Example:
|
|
59
|
-
* ```ts
|
|
60
|
-
* const Todo = types.model({
|
|
61
|
-
* task: types.string
|
|
62
|
-
* })
|
|
63
|
-
*
|
|
64
|
-
* const TodoStore = types.model({
|
|
65
|
-
* todos: types.array(Todo)
|
|
66
|
-
* }).actions(self => ({
|
|
67
|
-
* add(todo) {
|
|
68
|
-
* self.todos.push(todo);
|
|
69
|
-
* }
|
|
70
|
-
* }))
|
|
71
|
-
*
|
|
72
|
-
* const s = TodoStore.create({ todos: [] })
|
|
73
|
-
*
|
|
74
|
-
* let disposer = onAction(s, (call) => {
|
|
75
|
-
* console.log(call);
|
|
76
|
-
* })
|
|
77
|
-
*
|
|
78
|
-
* s.add({ task: "Grab a coffee" })
|
|
79
|
-
* // Logs: { name: "add", path: "", args: [{ task: "Grab a coffee" }] }
|
|
80
|
-
* ```
|
|
81
|
-
*
|
|
82
|
-
* @param target
|
|
83
|
-
* @param listener
|
|
84
|
-
* @param attachAfter (default false) fires the listener *after* the action has executed instead of before.
|
|
85
|
-
* @returns
|
|
86
|
-
*/
|
|
87
|
-
export declare function onAction(target: IAnyStateTreeNode, listener: (call: ISerializedActionCall) => void, attachAfter?: boolean): IDisposer;
|