ts-action TypeScript Redux动作创建器

如果你正在用 TypeScript 做 Redux,得试试ts-action。它是专门为 Redux 量身定做的 TypeScript 动作创建工具,核心理念就是通过静态类型来约束和简化 Redux 中的动作创建过程。比起传统手动创建常量和 action,使用ts-action,你只需要传入一个参数,它就能帮你搞定类型安全的动作创建。编译时的类型检查也能有效避免运行时的错误。

比如,传统的写法长这样:

const ACTION_TYPE = 'ACTION_TYPE';
const createAction = () => ({ type: ACTION_TYPE });

ts-action的写法就简洁多了:

import { createAction } from 'ts-action';
const ACTION_TYPE = 'ACTION_TYPE';
const createAction = createAction();

更牛的是,ts-action-immer结合了Immer,让你在不可变数据时,能像操作普通数据一样直观。举个例子,你可以直接在 action creators 里修改 state,Immer会帮你自动副本。

再加上ts-action-operators,你可以使用条件动作、组合多个动作,逻辑复杂的需求也能轻松应对。,这些库让你在 TypeScript 环境下使用 Redux 更高效、更安全,减少了多冗余代码和潜在错误。如果你是 Redux+TypeScript 的用户,这套工具值得试试!

zip
ts-action-master.zip 预估大小:70个文件
folder
ts-action-master 文件夹
file
.gitignore 48B
file
package.json 917B
file
CONTRIBUTING.md 94B
file
LICENSE 1KB
folder
packages 文件夹
folder
ts-action-operators 文件夹
file
tsconfig-test.json 148B
file
package.json 2KB
file
tsconfig-dist-cjs.json 232B
file
tslint.json 298B
file
package-dist.json 181B
file
tsconfig-dist-es5.json 169B
file
CHANGELOG.md 6KB
file
tsconfig.json 401B
folder
scripts 文件夹
file
pack.js 609B
file
README.md 5KB
file
tsconfig-dist-es2015.json 175B
folder
source 文件夹
file
ofType.ts 650B
file
foobar-spec.ts 987B
file
toPayload-spec.ts 861B
file
toPayload.ts 394B
file
act.ts 4KB
file
act-spec.ts 6KB
file
ofType-spec.ts 7KB
file
index.ts 217B
folder
ts-action 文件夹
file
tsconfig-test.json 148B
file
package.json 2KB
file
tsconfig-dist-cjs.json 232B
file
tslint.json 263B
file
package-dist.json 181B
file
CHANGELOG.md 11KB
file
tsconfig.json 401B
file
tsconfig-dist-esm5.json 169B
folder
scripts 文件夹
file
pack.js 609B
file
README.md 11KB
file
tsconfig-dist-esm2015.json 175B
folder
source 文件夹
file
foobar-spec.ts 2KB
file
reducer-spec.ts 5KB
file
isType-spec.ts 4KB
file
guard-spec.ts 4KB
file
action-spec.ts 12KB
file
action.ts 4KB
file
guard.ts 517B
file
reducer.ts 2KB
file
index.ts 291B
file
reducer-experiment-spec.ts 5KB
file
isType.ts 436B
file
snippet-spec.ts 506B
file
types.ts 413B
folder
ts-action-immer 文件夹
file
tsconfig-test.json 148B
file
package.json 2KB
file
tsconfig-dist-cjs.json 232B
file
tslint.json 263B
file
package-dist.json 181B
file
tsconfig-dist-es5.json 169B
file
CHANGELOG.md 2KB
file
tsconfig.json 401B
folder
scripts 文件夹
file
pack.js 609B
file
README.md 2KB
file
tsconfig-dist-es2015.json 175B
folder
source 文件夹
file
reducer-spec.ts 4KB
file
reducer.ts 1KB
file
index.ts 189B
file
snippet-spec.ts 538B
folder
.github 文件夹
file
FUNDING.yml 721B
folder
scripts 文件夹
file
bump.js 2KB
file
README.md 773B
folder
.circleci 文件夹
file
config.yml 698B
folder
docs 文件夹
file
index.md 2KB
file
_config.yml 27B
file
.editorconfig 259B
file
yarn.lock 120KB
...
zip 文件大小:100.3KB