diff --git a/CHANGELOG.md b/CHANGELOG.md index 93eb62c..101c2a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,37 @@ ## master +## [1.3.0](https://github.com/foca-js/foca/compare/v1.2.1...v1.3.0)  (2022-12-17) + +- `setState` 的回调模式支持返回不完整数据 + +```typescript +defineModel('unique_name', { + initialState: { a: 'a', b: 'b' }, + methods: { + test() { + this.setState(() => { + return { a: 'xxx' }; + }); + console.log(this.state); // { a: 'xxx', b: 'b' } + }, + }, +}); +``` + +- 传给 reducer 的 `initialState` 不再执行深拷贝,而是在开发环境下进行冻结处理以防开发者错误操作 + +```typescript +const initialState = { a: 'a', b: 'b' }; + +defineModel('unique_name', { + initialState: initialState, +}); + +// 修改失败,严格模式下会报错 +// TypeError: Cannot assign to read only property 'a' of object '#' +initialState.a = 'xxx'; +``` + ## [1.2.1](https://github.com/foca-js/foca/compare/v1.2.0...v1.2.1)  (2022-11-11) - 销毁模型时可能触发`onChange`勾子 diff --git a/package.json b/package.json index 53e5687..2fcd945 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foca", - "version": "1.2.1", + "version": "1.3.0", "repository": "git@github.com:foca-js/foca.git", "homepage": "https://foca.js.org", "keywords": [