Coder Social home page Coder Social logo

Comments (5)

MarlBurroW avatar MarlBurroW commented on May 18, 2024 2

Yes, sounds great for me ! I think it's important because it allow to create more complex flow when a socket event is triggered:

EXAMPLE:

actions: {
    SOCKET_USER_MESSAGE: (context, payload) => {
      context.dispatch('new_message_notification', payload);
      context.commit('add_message', payload);
      AudioManager.play('new_message_received');
    }
  }

from vue-socket.io.

MetinSeylan avatar MetinSeylan commented on May 18, 2024 1

added roadmap

from vue-socket.io.

michgeek avatar michgeek commented on May 18, 2024

hey @MarlBurroW can you tell more about this ? I'm not sure to understand, maybe I can help

from vue-socket.io.

MarlBurroW avatar MarlBurroW commented on May 18, 2024

Hey, i'll try to explain you:

With Vuex, you can:

Currently, with Vue-Socket.io, you can trigger Vuex mutations on a socket.io event by prefixing the name of the mutation with "SOCKET_".

BUT (if I'm not wrong) you can't dispatch actions by this same way.
it could be nice to do the same thing for actions, because sometime you need to trigger more than one mutation on a socket event. Sometime you need to make some other operations, asynchrone calls, etc... and actions are made for that.

from vue-socket.io.

michgeek avatar michgeek commented on May 18, 2024

What do you think of having the same concept for actions ?

{
  mutations: {
    my_mutation: (state) => { /*...*/ },
    another_mutation: (state) => { /*...*/ },
    SOCKET_USER_MESSAGE: (state) => { /*...*/ }
  ],
  actions: {
    SOCKET_USER_MESSAGE: (context, payload) => {
      // ... do things ...
      context.dispatch('my_mutation', payload);
      context.dispatch('another_mutation', payload);
    }
  }
}

You can decide to declare the socket event either in actions or mutations or both

from vue-socket.io.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.