From 57ad424c2c79a5c396e2725c5077775a5026bb70 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Mon, 29 Mar 2021 14:17:26 +0200 Subject: [PATCH] docs: wip --- docs/core-concepts/plugins.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 -- 2.47.2