Problem with handleEvents option in makeServicePlugin method
See original GitHub issueI have a problem, that is described there: https://github.com/feathersjs-ecosystem/feathers-vuex/issues/397 so I thought, that for now I would refresh other services by using handleEvents property, but it seems to not appear in the state of the model (I don’t know if it is supposed to), but also it’s not working (I put console.log there, and it’s not called).
Steps to reproduce
This is what I did:
// store/services/roles.js
const servicePlugin = makeServicePlugin({
Model: Role,
service: feathersClient.service(servicePath),
servicePath,
handleEvents: {
created: (item, { model, models }) => {
console.log("roles: created event");
return true;
},
... // Same with the rest of handlers
}
});
When it wasn’t working, I also added this part:
// plugins/feathers.js
const {
makeServicePlugin,
makeAuthPlugin,
BaseModel,
models,
FeathersVuex
} = feathersVuex(feathersClient, {
serverAlias: "api"
idField: "id" // Using sequelize
debug: true,
whitelist: ["$regex", "$options"],
enableEvents: true,
handleEvents: {
created: () => true,
updated: () => true,
patched: () => true,
removed: () => true
}
});
Is there something I am doing wrong? It seems straightforward, but no luck so far. If you will need more details, I will try to create a bigger example
Expected behavior
Handlers are called when I create an object.
Actual behavior
Handlers are not called.
System configuration
Module versions
"feathers-vuex": "^3.9.4",
"@feathersjs/feathers": "^4.5.3",
"@feathersjs/socketio-client": "^4.5.4",
"@vue/composition-api": "^0.5.0",
"feathers-hooks-common": "^5.0.3",
"nuxt": "^2.12.2",
"socket.io-client": "^2.3.0",
NodeJS version: v13.13.0
Operating System: Ubuntu 19.10
Browser Version: Mozilla 75.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Service Plugin | FeathersVuex
The makeServicePlugin method creates a vuex plugin which connects a Feathers ... This is handled through the new handleEvents option on the service...
Read more >feathers-vuex: Versions - Openbase
import { makeServicePlugin } from 'feathers-vuex' import { feathersClient } ... This is handled through the new handleEvents option on the service plugin....
Read more >Integration of FeathersJS, Vue, and Nuxt for the artisan ...
[x] Tell us about the problem your pull request is solving. Currently, the BaseModel has ... (b) The service method has been renamed...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think the offending code is in
make-service-plugin.ts
.The handlers passed in are being overridden. I think just negating the if statement would do the trick. (
if(!options.handleEvents[eventName])
)The fix for this is available in
feathers-vuex@3.10.0