2.0.0-alpha.16 (2021-05-04)
- devtools: display getters in components (810b969)
2.0.0-alpha.15 (2021-05-04)
- devtools: fix devtools attach (017795a)
2.0.0-alpha.14 (2021-05-03)
- devtools: work with stores added before app.use (#444) (21f917f)
- devtools: add getters to devtools (c4bf761)
- mark getters as readonly (fcbeb95)
- plugins: allow chaining (3a49d34)
- mapHelpers: warn on array mapStores (d385bd9)
- pass options to context in plugins (c8ad19f)
- types: expose PiniaPluginContext (94d12e7)
- add plugin api wip (50bc807)
- plugins: allow void return (5ef7140)
- plugins: pass a context object to plugins instead of app (bcb4ec3)
- add plugin api wip (b5c928d)
- store: reuse store instances when possible (14f5a5f)
-
store: getters now receive the state as their first argument and it's properly typed so you can write getters with arrow functions:
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 explicitly type the getter return type. The same limitation exists in Vue for computed properties and it's a known limitation in TypeScript: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.
-
plugins: To improve the plugin api capabilities,
pinia.use()
now receives a context object instead of justapp
:// replace pinia.use((app) => {}) // with pinia.use(({ app }) => {})
Check the new documentation for Plugins!
2.0.0-alpha.13 (2021-04-10)
- subscribe: remove subscription when unmounted (10e1c30)
- types: fail on async patch (c254a8a)
2.0.0-alpha.12 (2021-04-09)
2.0.0-alpha.11 (2021-04-09)
- types: enable autocomplete in object (b299ff0)
- mapWritableState (3218bdb)
- mapState: accept functions (e2f2b92)
- mapStores: allow custom suffix (c957fb9)
- types: allow extending mapStores suffix (f14c7b9)
- add mapActions (b5d27fb)
- add mapStores (d3d9327)
- mapState with array (0e05811)
- mapState with object (06805db)
- types: expose DefineStoreOptions (c727070)
2.0.0-alpha.10 (2021-04-01)
2.0.0-alpha.9 (2021-03-31)
- types: pass custom properties to stores (d26df6e)
2.0.0-alpha.8 (2021-03-29)
- devtools: logo and titles (0963fd0)
2.0.0-alpha.7 (2021-01-21)
2.0.0-alpha.6 (2020-12-31)
setActiveReq()
has been renamed tosetActivePinia()
. And now receives the application's pinia as the first parameter instead of an arbitrary object (like a Node http request). This affects particularly users doing SSR but also enables them to write universal code.
2.0.0-alpha.5 (2020-10-09)
- all store properties (
id
,state
,patch
,subscribe
, andreset
) are now prefixed with$
to allow properties defined with the same type and avoid types breaking. Tip: you can refactor your whole codebase with F2 (or right-click + Refactor) on each of the store's properties
2.0.0-alpha.4 (2020-09-29)
- detach stores creation from currentInstance (dc31736)
2.0.0-alpha.3 (2020-09-28)
- rename createStore to defineStore (a9ad160)
- renamed
createStore
todefineStore
.createStore
will be marked as deprecated during the alpha releases and then be dropped.
2.0.0-alpha.2 (2020-09-25)
- add devtools support (849cb3f)
2.0.0-alpha.1 (2020-09-22)
- access the state and getters through
this
(#190) (6df18ef) - merge all properties under this (d5eaac1)
state
properties no longer need to be accessed throughstore.state
getters
no longer receive parameters, access the store instance viathis
: directly callthis.myState
to read state and other getters. Update 2021-04-02:getters
receive the state again as the first parameter