Skip to content

Commit

Permalink
build(3.4.12): add snap to witness
Browse files Browse the repository at this point in the history
  • Loading branch information
fantasticsoul committed Dec 2, 2023
1 parent c07ba3d commit 04c2ed1
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "helux",
"version": "3.4.11",
"version": "3.4.12",
"description": "A state library core that integrates atom, signal, collection dep, derive and watch, it supports all react like frameworks( including react 18 ).",
"keywords": [],
"author": {
Expand Down
2 changes: 1 addition & 1 deletion packages/helux-core/src/consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createSymbol, HAS_SYMBOL } from '../helpers/sym';
export { EVENT_NAME, FROM, LOADING_MODE } from './user';
export { HAS_SYMBOL };

export const VER = '3.4.11';
export const VER = '3.4.12';

export const PROD_FLAG = true;

Expand Down
7 changes: 4 additions & 3 deletions packages/helux-core/src/factory/createMutate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ function runMutateFnItem(options: { target: SharedState; desc?: string; forTask?
return callMutateFn(target, { ...item, forTask });
}

function makeWitness(target: SharedState, desc: string, oriDesc: string) {
function makeWitness(target: SharedState, desc: string, oriDesc: string, snap: any) {
return {
call: () => runMutateFnItem({ target, desc }), // 呼叫同步函数的句柄
callTask: () => Promise.resolve(runMutateFnItem({ target, desc, forTask: true })), // 呼叫异步函数的句柄
desc,
oriDesc,
snap,
};
}

Expand Down Expand Up @@ -77,7 +78,7 @@ function configureMutateFn(options: IConfigureMutateFnOpt) {
internal.mutateFnDict[stdFnItem.desc] = stdFnItem;
const dict = { [stdFnItem.desc]: stdFnItem };
watchAndCallMutateDict({ target, dict });
return makeWitness(target, stdFnItem.desc, stdFnItem.oriDesc);
return makeWitness(target, stdFnItem.desc, stdFnItem.oriDesc, internal.snap);
}

/**
Expand All @@ -90,7 +91,7 @@ function configureMutateDict(options: IConfigureMutateDictOpt): any {
watchAndCallMutateDict({ target, dict });
const witnessDict: Dict<MutateWitness> = {}; // 具体类型定义见 types-api multiDict
Object.keys(dict).forEach((desc) => {
witnessDict[desc] = makeWitness(target, desc, desc);
witnessDict[desc] = makeWitness(target, desc, desc, internal.snap);
});
return witnessDict;
}
Expand Down
1 change: 1 addition & 0 deletions packages/helux-core/src/types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ export type MutateWitness<T = any> = {
oriDesc: string;
/** 内部生成的实际描述值 */
desc: string;
snap: T;
};

// for dict
Expand Down

0 comments on commit 04c2ed1

Please sign in to comment.