Skip to content

Commit

Permalink
# 4.5.3 2022-05-24
Browse files Browse the repository at this point in the history
* [design] move the reset version modify to common reset function.
  • Loading branch information
wangyi committed May 24, 2022
1 parent 228c7f2 commit c124c26
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 6 deletions.
6 changes: 5 additions & 1 deletion docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,8 @@ in this version, `runtime.cache` used in MiddleWare is independent.

# 4.5.2 2022-05-24

* [bug] resolve the typescript method name about `recreate`.
* [bug] resolve the typescript method name about `recreate`.

# 4.5.3 2022-05-24

* [design] move the reset version modify to common reset function.
6 changes: 5 additions & 1 deletion docs/zh/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,8 @@

# 4.5.2 2022-05-24

* [bug] 修复 typescript 无法使用 `recreate` 的问题。
* [bug] 修复 typescript 无法使用 `recreate` 的问题。

# 4.5.3 2022-05-24

* [design] reset version 支持所有 reset。
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-reducer",
"version": "4.5.2",
"version": "4.5.3",
"main": "dist/agent-reducer.mini.js",
"typings": "index.d.ts",
"author": "Jimmy.Harding",
Expand Down
3 changes: 2 additions & 1 deletion src/libs/connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
agentMethodName,
agentModelInstanceInitialedKey,
agentModelMethodsCacheKey,
agentModelResetKey,
agentModelResetKey, agentModelResetVersionKey,
agentSharingMiddleWareKey,
agentSharingTypeKey, agentStrictModelActMethodKey, agentStrictModelKey, DefaultActionType,
} from './defines';
Expand All @@ -25,6 +25,7 @@ export function resetModel<
entity[agentActionKey] = undefined;
entity[agentModelMethodsCacheKey] = undefined;
entity[agentModelInstanceInitialedKey] = undefined;
entity[agentModelResetVersionKey] = (entity[agentModelResetVersionKey] || 0) + 1;
unmountEffects(entity);
entity[agentEffectsKey] = undefined;
entity[agentErrorConnectionKey] = undefined;
Expand Down
2 changes: 0 additions & 2 deletions src/libs/sharing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,7 @@ export function weakSharing<
const ModelLike = Array.isArray(initialParams)
? factory(...initialParams) : factory();
const newInstance = createWeakSharingModel<S, T>(ModelLike, reset);
const lastVersion = ref.current[agentModelResetVersionKey];
Object.assign(ref.current, newInstance);
ref.current[agentModelResetVersionKey] = (lastVersion || 0) + 1;
initialParams = null;
initialed = false;
};
Expand Down

0 comments on commit c124c26

Please sign in to comment.