Files
kaunter/public/js/Class/SubscribePusher.js
T
2024-11-08 22:00:17 +08:00

20 lines
551 B
JavaScript
Vendored

class SubscribePusher {
constructor(subscribe, event, apikey) {
this.subscribe = subscribe;
this.event = event;
this.apikey = apikey;
this.pusher = new Pusher(this.apikey, {
cluster: 'ap1', // Replace 'your_cluster' with the actual cluster of your Pusher app
});
}
channel_subscribe(callback) {
let channel = this.pusher.subscribe(this.subscribe);
channel.bind(this.event, function(data){
callback(data);
});
}
}
export default SubscribePusher;