]> git.ipfire.org Git - thirdparty/vuejs/pinia.git/commitdiff
docs: show how to install pinia
authorEduardo San Martin Morote <posva13@gmail.com>
Fri, 25 Sep 2020 09:40:04 +0000 (11:40 +0200)
committerEduardo San Martin Morote <posva13@gmail.com>
Fri, 25 Sep 2020 09:41:22 +0000 (11:41 +0200)
README.md
src/store.ts

index 621fa563c5846f79dc7ec698889b8606b971d445..969b0ffd4f9370455baeb41ee62ad0994840610b 100644 (file)
--- a/README.md
+++ b/README.md
@@ -71,6 +71,19 @@ npm install pinia@next
 
 ## Usage
 
+### Install the plugin
+
+Create a pinia (the root store) and pass it to app:
+
+```js
+import { createPinia } from 'pinia'
+
+app.use(createPinia())
+```
+
+This will also add devtools support.
+**NOTE**: this API is still experimental and is currently only used for devtools support but that might change in the future
+
 ### Creating a Store
 
 You can create as many stores as you want, and they should each exist in different files:
index 0776c79661b417f864f6fcfc30dbcc241cac9311..868c0849496bb8043334aedfd52bcd1e029d3b49 100644 (file)
@@ -172,6 +172,9 @@ export function buildStore<
   return store
 }
 
+// only warn the dev once
+let isDevWarned: boolean | undefined
+
 /**
  * Creates a `useStore` function that retrieves the store instance
  * @param options - options to define the store
@@ -208,12 +211,14 @@ export function createStore<
         const app = getClientApp()
         if (app) {
           addDevtools(app, store, req)
-        } else {
+        } else if (!isDevWarned && !__TEST__) {
+          isDevWarned = true
           console.warn(
             `[🍍]: store was instantiated before calling\n` +
               `app.use(pinia)\n` +
               `Make sure to install pinia's plugin by using createPinia:\n` +
-              `linkto docs TODO`
+              `https://github.com/posva/pinia/tree/v2#install-the-plugin\n` +
+              `It will enable devtools and overall a better developer experience.`
           )
         }
       }