jaggy / vue-pusher Goto Github PK
View Code? Open in Web Editor NEWA small pusher plugin for vue.js
A small pusher plugin for vue.js
This function, subscribe()
and unsubscribe()
is undefined when using this.$pusher
in Nuxt.js. I already set the mode to client, follow the instruction, but nothing work. Here's the plugin vue-pusher.js fiile I made.
import Vue from "vue";
// import VuePusher from "vue-pusher";
export default ({$config: {pusherKey, pusherCluster}}) => {
Vue.use(VuePusher, {api_key: pusherKey, options: {cluster: pusherCluster, encrypted: false}})
}
And using it in the pages like this:
export default {
......
mounted() {
this.pusher()
},
methods: {
pusher() {
var channel = this.$pusher.subscribe('railway')
channel.bind('01', (data) => {
// do with the data
})
},
.......
},
.....
}
Any idea what is wrong with this conifiguration? thank you
Uncaught ReferenceError: Pusher is not defined
in lines:
this.pusher = new Pusher(api_key, options);
when I try to use:
Vue.use(require('vue-pusher'), {
api_key: 'xxxx',
options: {
encrypted: true,
}
});
should i install something else? https://www.npmjs.com/package/pusher maybe?
this.$pusher.disconnect();
not working well
Almost exactly what I was after though there doesn't seem to be the interface for turning on debugging, e.g.
Pusher.logToConsole = true
Am I missing something?
Trying to install the plugin on a Vue 3 project (w/ Nuxt 3) it errors:
500
Cannot set properties of undefined (setting 'pusher')
at Object.install (http://localhost:3000/_nuxt/node_modules/.vite/deps/vue-pusher.js?v=ae3370f2:6061:30)
at Object.use (http://localhost:3000/_nuxt/node_modules/.vite/deps/vue.js?v=ae3370f2:4690:18)
at http://localhost:3000/_nuxt/plugins/pusher.client.js:4:18
at fn (http://localhost:3000/_nuxt/node_modules/.pnpm/[email protected]/node_modules/nuxt/dist/app/nuxt.mjs?v=ae3370f2:141:27)
at callWithNuxt (http://localhost:3000/_nuxt/node_modules/.pnpm/[email protected]/node_modules/nuxt/dist/app/nuxt.mjs?v=ae3370f2:146:12)
at applyPlugin (http://localhost:3000/_nuxt/node_modules/.pnpm/[email protected]/node_modules/nuxt/dist/app/nuxt.mjs?v=ae3370f2:92:29)
at applyPlugins (http://localhost:3000/_nuxt/node_modules/.pnpm/[email protected]/node_modules/nuxt/dist/app/nuxt.mjs?v=ae3370f2:101:11)
at async initApp (http://localhost:3000/_nuxt/home/akiraserikawa/Sites/nuxt-demo/node_modules/.pnpm/[email protected]/node_modules/nuxt/dist/app/entry.mjs:39:7)
this caused by changes in Vue 3, where Vue.prototype
does not exist anymore, so the plugin cannot work:
module.exports = {
install: function (Vue, options) {
var pusher = new VuePusher(options.api_key, options.options);
Vue.prototype.pusher = pusher;
Vue.prototype.$pusher = pusher.pusher; // Just in case they want to manage it themselves.
}
};
I guess it would require the plugin to use app.config.globalProperties
instead.
https://vuejs.org/api/application.html#app-config-globalproperties
Trying to implement user authentication, but receiving this error: "this.$pusher.signin() in not a function"
Getting errors on some browsers that can't connect to pusher 4.2.1, is there a place we can update which version of pusher is being loaded or can you update to 4.3.*
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.