question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problem with handleEvents option in makeServicePlugin method

See original GitHub issue

I 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:closed
  • Created 3 years ago
  • Comments:9 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
hamiltoescommented, Apr 30, 2020

I think the offending code is in make-service-plugin.ts.

    const options = Object.assign({}, defaults, globalOptions, config)
    const {
      Model,
      service,
      namespace,
      nameStyle,
      instanceDefaults,
      setupInstance,
      preferUpdate
    } = options

    events.forEach(eventName => {
      if (options.handleEvents[eventName])
        options.handleEvents[eventName] = () => options.enableEvents || true
    })

The handlers passed in are being overridden. I think just negating the if statement would do the trick. (if(!options.handleEvents[eventName]))

0reactions
marshallswaincommented, May 2, 2020

The fix for this is available in feathers-vuex@3.10.0

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found