From: Eduardo San Martin Morote Date: Mon, 29 Mar 2021 12:17:26 +0000 (+0200) Subject: docs: wip X-Git-Tag: v2.0.0-alpha.14~39 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=57ad424c2c79a5c396e2725c5077775a5026bb70;p=thirdparty%2Fvuejs%2Fpinia.git docs: wip --- diff --git a/docs/core-concepts/plugins.md b/docs/core-concepts/plugins.md index fb1a413b..e3f53be9 100644 --- a/docs/core-concepts/plugins.md +++ b/docs/core-concepts/plugins.md @@ -9,9 +9,17 @@ Pinia stores can be fully extended thanks to a low level API. Here is a list of - Implement side effects like local storage - Apply **only** to specific stores -Plugins are added to pinia with `pinia.use()`: +Plugins are added to pinia with `pinia.use()`. The simplest example is adding a property to all stores by returning an object: ```js // add a property named `secret` to every store that is created after this plugin is installed -pinia.use(() => ({ secret: '' })) +pinia.use(() => ({ secret: 'the cake is a lie' })) + +// in another file +const store = useStore() +store.secret // 'the cake is a lie' ``` + +## TypeScript + +When adding new properties to stores