Vue2 Socketcluster
Why ??
- This package wraps the client requests inside promises.
- No need to assign socket to the root. It's available everywhere!
Installation
npm install vue2-socketcluster --save
Usage
Vue el:"#app" { return authToken:null } methods: { // Do something with the error.. I suggest adding alertify } { let vm = this vm$socket } --------------------------- // Example - some component name:'test' { return users: } { let vm = this // Traditional vm$socket // Promises { let results = {} resultsfirst_result = await vm$socket resultssecond_result = await vm$socket return results } }
Test
cd testnpm inpm run dev
Open up the browser and you will see "Connected" and the status var outputed... assuming you have an instance of socketcluster running on localhost:3000.