as-model 0.4.0 → 0.4.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.
package/dist/index.js CHANGED
@@ -699,16 +699,18 @@ function createUpdateFn(updater, middleWare) {
699
699
  if (Object.is(u.model, model) && Object.is(u.state, state)) {
700
700
  return u;
701
701
  }
702
- effect(function(up) {
703
- up.notify({
704
- type: null,
705
- method: null,
706
- prevInstance: u.instance,
707
- instance: u.instance,
708
- prevState: u.state,
709
- state
702
+ if (!args.silence) {
703
+ effect(function(up) {
704
+ up.notify({
705
+ type: null,
706
+ method: null,
707
+ prevInstance: u.instance,
708
+ instance: u.instance,
709
+ prevState: u.state,
710
+ state
711
+ });
710
712
  });
711
- });
713
+ }
712
714
  return _object_spread_props(_object_spread({}, u), {
713
715
  model,
714
716
  initialized: true,
@@ -1292,6 +1294,18 @@ function createStore(modelLike) {
1292
1294
  getStoreInstance: function getStoreInstance() {
1293
1295
  return extractInstance(updater, void 0, propertiesCache);
1294
1296
  },
1297
+ config: function config4(customizedConfig) {
1298
+ updater.mutate(function(u) {
1299
+ var middleWares = customizedConfig.middleWares, rest = _object_without_properties(customizedConfig, [
1300
+ "middleWares"
1301
+ ]);
1302
+ var updaterConfig = u.config;
1303
+ var nextUpdaterConfig = _object_spread({}, updaterConfig, rest);
1304
+ return _object_spread_props(_object_spread({}, u), {
1305
+ config: nextUpdaterConfig
1306
+ });
1307
+ });
1308
+ },
1295
1309
  update: function update(args) {
1296
1310
  var updateArgs = args !== null && args !== void 0 ? args : {};
1297
1311
  if (updateArgs.key) {
@@ -109,6 +109,14 @@ function createStore(modelLike, config = {}) {
109
109
  getStoreInstance() {
110
110
  return extractInstance(updater, void 0, propertiesCache);
111
111
  },
112
+ config(customizedConfig) {
113
+ updater.mutate((u) => {
114
+ const _a = customizedConfig, { middleWares } = _a, rest = __objRest(_a, ["middleWares"]);
115
+ const updaterConfig = u.config;
116
+ const nextUpdaterConfig = __spreadValues(__spreadValues({}, updaterConfig), rest);
117
+ return __spreadProps(__spreadValues({}, u), { config: nextUpdaterConfig });
118
+ });
119
+ },
112
120
  update(args) {
113
121
  const updateArgs = args != null ? args : {};
114
122
  if (updateArgs.key) {
@@ -73,16 +73,18 @@ function createUpdateFn(updater, middleWare) {
73
73
  if (Object.is(u.model, model) && Object.is(u.state, state)) {
74
74
  return u;
75
75
  }
76
- effect((up) => {
77
- up.notify({
78
- type: null,
79
- method: null,
80
- prevInstance: u.instance,
81
- instance: u.instance,
82
- prevState: u.state,
83
- state
76
+ if (!args.silence) {
77
+ effect((up) => {
78
+ up.notify({
79
+ type: null,
80
+ method: null,
81
+ prevInstance: u.instance,
82
+ instance: u.instance,
83
+ prevState: u.state,
84
+ state
85
+ });
84
86
  });
85
- });
87
+ }
86
88
  return __spreadProps(__spreadValues({}, u), {
87
89
  model,
88
90
  initialized: true,
@@ -151,5 +153,6 @@ function createUpdater(model, middleWare, config = {}) {
151
153
  return updater;
152
154
  }
153
155
  export {
156
+ createUpdateFn,
154
157
  createUpdater
155
158
  };
package/index.d.ts CHANGED
@@ -108,7 +108,9 @@ export declare interface Store<
108
108
  key?: Key<M, R>;
109
109
  initialState?: PickState<M>;
110
110
  state?: PickState<M>;
111
+ silence?: boolean;
111
112
  }) => void;
113
+ config(customizedConfig: Config);
112
114
  destroy: () => void;
113
115
  payload: <P>(
114
116
  callback?: (payload: P | undefined) => P | undefined
package/package.json CHANGED
@@ -1,68 +1,68 @@
1
- {
2
- "private": false,
3
- "name": "as-model",
4
- "version": "0.4.0",
5
- "description": "This is a model state management tool",
6
- "license": "MIT",
7
- "author": "Jimmy.Harding",
8
- "homepage": "https://github.com/filefoxper/a-model",
9
- "repository": {
10
- "type": "git",
11
- "url": "https://github.com/filefoxper/a-model"
12
- },
13
- "main": "dist/index.js",
14
- "module": "esm/index.js",
15
- "files": [
16
- "dist",
17
- "esm",
18
- "index.d.ts"
19
- ],
20
- "scripts": {
21
- "build": "node ./build.js",
22
- "docs": "docsify serve ./docs",
23
- "lint": "eslint src --fix --ext .ts,.tsx ",
24
- "lint-init": "eslint --init",
25
- "test": "jest --coverage"
26
- },
27
- "typings": "index.d.ts",
28
- "devDependencies": {
29
- "@babel/cli": "^7.27.2",
30
- "@babel/core": "^7.27.4",
31
- "@babel/eslint-parser": "^7.27.5",
32
- "@babel/plugin-transform-runtime": "^7.27.4",
33
- "@babel/preset-env": "^7.27.2",
34
- "@babel/preset-typescript": "^7.27.1",
35
- "@babel/runtime": "^7.27.6",
36
- "@pmnps/plugin-publish": "4.5.0",
37
- "@types/jest": "^29.5.14",
38
- "babel-jest": "29.7.0",
39
- "esbuild": "^0.25.0",
40
- "esbuild-plugin-es5": "2.1.1",
41
- "eslint": "^8.49.0",
42
- "eslint-config-airbnb": "^19.0.4",
43
- "eslint-config-airbnb-typescript": "^17.1.0",
44
- "eslint-config-prettier": "^9.0.0",
45
- "eslint-import-resolver-typescript": "^3.6.0",
46
- "eslint-plugin-import": "^2.28.1",
47
- "eslint-plugin-jsx-a11y": "^6.7.1",
48
- "eslint-plugin-prettier": "^5.0.0",
49
- "eslint-plugin-react": "^7.33.2",
50
- "eslint-plugin-react-hooks": "^4.6.0",
51
- "eslint-plugin-unused-imports": "^2.0.0",
52
- "eslint-webpack-plugin": "^4.0.1",
53
- "jest": "29.7.0",
54
- "jest-environment-jsdom": "29.7.0",
55
- "pmnps": "^4.5.3",
56
- "prettier": "^3.0.3",
57
- "prettier-eslint": "^15.0.1",
58
- "prettier-eslint-cli": "^7.1.0",
59
- "ts-node": "^10.8.1",
60
- "typescript": "^4.9.5"
61
- },
62
- "keywords": [
63
- "model",
64
- "state",
65
- "state-management",
66
- "typescript"
67
- ]
68
- }
1
+ {
2
+ "private": false,
3
+ "name": "as-model",
4
+ "version": "0.4.2",
5
+ "description": "This is a model state management tool",
6
+ "license": "MIT",
7
+ "author": "Jimmy.Harding",
8
+ "homepage": "https://github.com/filefoxper/a-model",
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/filefoxper/a-model"
12
+ },
13
+ "main": "dist/index.js",
14
+ "module": "esm/index.js",
15
+ "files": [
16
+ "dist",
17
+ "esm",
18
+ "index.d.ts"
19
+ ],
20
+ "scripts": {
21
+ "build": "node ./build.js",
22
+ "docs": "docsify serve ./docs",
23
+ "lint": "eslint src --fix --ext .ts,.tsx ",
24
+ "lint-init": "eslint --init",
25
+ "test": "jest --coverage"
26
+ },
27
+ "typings": "index.d.ts",
28
+ "devDependencies": {
29
+ "@babel/cli": "^7.27.2",
30
+ "@babel/core": "^7.27.4",
31
+ "@babel/eslint-parser": "^7.27.5",
32
+ "@babel/plugin-transform-runtime": "^7.27.4",
33
+ "@babel/preset-env": "^7.27.2",
34
+ "@babel/preset-typescript": "^7.27.1",
35
+ "@babel/runtime": "^7.27.6",
36
+ "@pmnps/plugin-publish": "4.5.0",
37
+ "@types/jest": "^29.5.14",
38
+ "babel-jest": "29.7.0",
39
+ "esbuild": "^0.25.0",
40
+ "esbuild-plugin-es5": "2.1.1",
41
+ "eslint": "^8.49.0",
42
+ "eslint-config-airbnb": "^19.0.4",
43
+ "eslint-config-airbnb-typescript": "^17.1.0",
44
+ "eslint-config-prettier": "^9.0.0",
45
+ "eslint-import-resolver-typescript": "^3.6.0",
46
+ "eslint-plugin-import": "^2.28.1",
47
+ "eslint-plugin-jsx-a11y": "^6.7.1",
48
+ "eslint-plugin-prettier": "^5.0.0",
49
+ "eslint-plugin-react": "^7.33.2",
50
+ "eslint-plugin-react-hooks": "^4.6.0",
51
+ "eslint-plugin-unused-imports": "^2.0.0",
52
+ "eslint-webpack-plugin": "^4.0.1",
53
+ "jest": "29.7.0",
54
+ "jest-environment-jsdom": "29.7.0",
55
+ "pmnps": "^4.5.3",
56
+ "prettier": "^3.0.3",
57
+ "prettier-eslint": "^15.0.1",
58
+ "prettier-eslint-cli": "^7.1.0",
59
+ "ts-node": "^10.8.1",
60
+ "typescript": "^4.9.5"
61
+ },
62
+ "keywords": [
63
+ "model",
64
+ "state",
65
+ "state-management",
66
+ "typescript"
67
+ ]
68
+ }