From 0ec87e606d6ad1e0f2e6f212f7287599330810fd Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 3 May 2021 12:54:09 +0200 Subject: [PATCH] release: v0.4.0 --- CHANGELOG.md | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 58 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77ec38fe..c9479e06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,60 @@ +# [0.4.0](https://github.com/posva/pinia/compare/v0.3.1...v0.4.0) (2021-05-03) + +### Features + +- **pinia:** allow chaining pinia.use ([d5e7a6e](https://github.com/posva/pinia/commit/d5e7a6ea30bc4e1b3e4aa734fa0154258c9003c7)) +- **plugins:** pass a context object to plugins instead of app ([8176db4](https://github.com/posva/pinia/commit/8176db4e7edf3e2d77738437fbab73ffea0aee30)) +- **plugins:** pass options to plugins ([4d750ad](https://github.com/posva/pinia/commit/4d750adc05a2753f4abfae112fbeb1f2bc212a23)) +- **store:** pass state to getters as first argument ([9f3132b](https://github.com/posva/pinia/commit/9f3132bd7a59c47f3bd9005695c4f1224dbaea16)) +- **types:** fail on async patch ([fe58fab](https://github.com/posva/pinia/commit/fe58fab1bdf95a4924672459aec88b1f4f87d0ba)) + +### Performance Improvements + +- **store:** reuse stores from parent to children components ([fcfda41](https://github.com/posva/pinia/commit/fcfda419efb1e40d68f8c75a6f441da453b9207b)) + +### BREAKING CHANGES + +- **store:** getters now receive the state as their first argument and it's properly typed so you can write getters with arrow functions: + + ```js + defineStore({ + state: () => ({ n: 0 }), + getters: { + double: (state) => state.n * 2, + }, + }) + ``` + + To access other getters, you must still use the syntax that uses `this` **but it is now necessary to explicitely type the getter return type**. The same limitation exists in Vue for computed properties and it's a known limitation in TypeScript: + + ```ts + defineStore({ + state: () => ({ n: 0 }), + getters: { + double: (state) => state.n * 2, + // the `: number` is necessary when accessing `this` inside of + // a getter + doublePlusOne(state): number { + return this.double + 1 + }, + }, + }) + ``` + + For more information, refer to [the updated documentation for getters](https://pinia.esm.dev/core-concepts/getters.html). + +- **plugins:** To improve the plugin api capabilities, `pinia.use()` + now receives a context object instead of just `pinia`: + + ```js + // replace + pinia.use((pinia) => {}) + // with + pinia.use(({ pinia, store }) => {}) + ``` + + Check the new documentation for [Plugins](https://pinia.esm.dev/core-concepts/plugins.html)! + ## [0.3.1](https://github.com/posva/pinia/compare/v0.3.0...v0.3.1) (2021-04-10) ### Bug Fixes diff --git a/package.json b/package.json index 59357ab6..bd3a88e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pinia", - "version": "0.3.1", + "version": "0.4.0", "description": "Intuitive, type safe and flexible Store for Vue", "main": "dist/pinia.cjs.js", "module": "dist/pinia.esm-bundler.js", -- 2.47.3