pinia-plugin-subscription 0.0.0-beta.12 → 0.0.0-beta.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -4
- package/dist/pinia-plugin-subscription.js +487 -475
- package/dist/pinia-plugin-subscription.umd.cjs +5 -5
- package/dist/types/index.d.ts +3 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -26,8 +26,8 @@ import App from './App.vue'
|
|
|
26
26
|
const app = createApp(App)
|
|
27
27
|
const pinia = createPinia()
|
|
28
28
|
|
|
29
|
-
// Register plugin (subscribers array, debug
|
|
30
|
-
pinia.use(createPlugin([myStoreSubscriber]))
|
|
29
|
+
// Register plugin (subscribers array, debug = list of target plugins)
|
|
30
|
+
pinia.use(createPlugin([myStoreSubscriber], ['my-plugin']))
|
|
31
31
|
|
|
32
32
|
app.use(pinia)
|
|
33
33
|
app.mount('#app')
|
|
@@ -65,6 +65,7 @@ class MyStore extends Store {
|
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
export const myStoreSubscriber = {
|
|
68
|
+
name: 'my-plugin'
|
|
68
69
|
invoke: (context, debug) => {
|
|
69
70
|
// create an instance of the Store subclass when options.storeOptions is present
|
|
70
71
|
const myStore = MyStore.customizeStore(context.store, context.options, debug)
|
|
@@ -110,9 +111,9 @@ export const myStoreSubscriber = {
|
|
|
110
111
|
|
|
111
112
|
Creates a Pinia plugin from the provided `subscribers` and optional `debug` flag. Each subscriber will be invoked with the Pinia plugin context when a store is registered.
|
|
112
113
|
|
|
113
|
-
### `
|
|
114
|
+
### `PluginSubscriberInterface`
|
|
114
115
|
|
|
115
|
-
The `
|
|
116
|
+
The `PluginSubscriberInterface` interface has been extended: it's still an object with at least an `invoke(context: PiniaPluginContext, debug?: boolean)` method, but it can now expose several useful properties for plugins:
|
|
116
117
|
|
|
117
118
|
- **`resetStoreCallback?: (store?: Store) => void`**: callback invoked when the store is reset.
|
|
118
119
|
- **`storeOnActionSubscription?: StoreOnActionSubscription`**: provides a native Pinia `onAction` subscription via a getter returning `{ store, callback }`.
|
|
@@ -179,3 +180,14 @@ Other small helpers exposed: `stateHas(property)`, `storeHas(property)` and `get
|
|
|
179
180
|
- Branches: **86.53%** (45/52)
|
|
180
181
|
- Functions: **100%** (38/38)
|
|
181
182
|
- Lines: **97.59%** (81/83)
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
## Notes
|
|
186
|
+
|
|
187
|
+
The $reset method is available for stores augmented by the plugin (also compositionApi store 😁).
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## License
|
|
192
|
+
|
|
193
|
+
MIT
|