News for hackers. Stuff that matters.
Re:Vue 3.0 Updates [slides] by TekMol on Saturday November 17, 2018 @11:42AM (#18476192)
Could you add the lines needed to the above example to make the user list grow / shrink real time via websockets?

Would be interested to see how you would implement that.

Re:Vue 3.0 Updates [slides] by gbuk2013 on Saturday November 17, 2018 @02:28PM (#18476946)
Pseudo-ish code because I’m typing from my phone.

Vuex code as per docs to create state.stuff and mutations.update_suff() then in main Vue instance

    mounted () {
      this.$socket.subscribe(‘stuff’, data => {
        this.$store.commit(‘update_stuff’, data);
      });
where $socket is a subscriber client I wrote wrapped as a Vue plugin.

Then inside the components

    computed () {
      stuff () {
        return this.$store.state.stuff;
      }
    }
then use stuff as in your example.

So very simple, and nothing that I couldn’t do without Vue but it takes care of the boring DOM manipulations and using the browser extension during development I can watch state change (which becomes interesting when there are multiple subscriptions with data combined).

Re:Vue 3.0 Updates [slides] by TekMol on Saturday November 17, 2018 @03:46PM (#18477315)
So the first step towards your solution would be to include vuex? Like this?

    <script src="/path/to/vuex.js"></script>
And then?

What are mounted() and computed()? They look like methods of a class?