Comments (3)
this could be useful!
I'm not sure what the plugin would be receiving, maybe an objects with functions to subscribe to changes and receive the store instance:
function piniaCache({ subscribe, patch }) {
subscribe((store, otherThings) => {})
subscribe('storeId', (store) => {})
patch('storeId', thing)
from pinia.
yeah, subscribe with function sounds good. We would need different ways do track the data:
- by state (i dont know if hooks are good here maybe before set the state and after)
- by actions with hooks
i think that is important to avoid dispatch mutations, actions (listeners) when i only need track a simple state property for example.
function piniaCache({ subscribe, patch }) {
...
subscribeState('storeId', (oldData, newData) => {})
subscribeBeforeAction('storeId', 'deleteItem', (payload) => {
return { ...payload, name: 'Kieling' }
})
// will receive name: 'Kieling' into payload and the rest
subscribeAfterAction('storeId', 'deleteItem', (payload) => { })
from pinia.
This has been implemented and documented in #416 and will be available in the next release
from pinia.
Related Issues (20)
- Nuxt3 useRoute update HOT 1
- current use vscode vue3.2+pinia project, Mouse click can not jump HOT 1
- Pinia stores imported from npm packages are not reactive or don't share the same context
- After entering the route, the first v-model binding value cannot be captured and updated. HOT 2
- 【$subscribe】When the state is an Array, "mutation.events.key" doesn't indicate the state's name. HOT 2
- Could add a destructuring method contains actions and non reactive property? HOT 1
- Typescript issue with getter within getter HOT 2
- "pinia": "^2.1.7", has bug,click button more time, the arr disaplay wrong. HOT 1
- SSR does not works on pinia with Nuxt on repeated component
- Return types of state variables with nested ref/computed properties don't match the specified type
- disposePinia missing types HOT 2
- Basic counter changed in getter not updated after upgrading to vue 3.4.29 HOT 2
- `Set operation on key "value" failed` when returning `readonly` ref in SSR HOT 5
- Disable console log "x store installed" messages HOT 1
- ref takes Object inheriting Map and returns Map object HOT 2
- Automatic detection of appropriate 'storesDirs' default for Nuxt 4 HOT 3
- A way to detect a composable is being used in setup store
- docs: Chinese docs api documentation is 404
- Cannot find module 'pinia/dist/pinia.mjs' HOT 1
- defineStore 的参数类型错误
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pinia.