bluedevil2k
bluedevil2k

Reputation: 9501

Listen to Multiple Events on a Pusher Channel

I'm trying to listen on a single channel to multiple events using Pusher.js.

I thought you had to separate the event names by a space, but that doesn't seem to be working. I've tried comma limited and also passing an array of strings.

channel.bind(
"open_auction close_auction"
"open_auction, close_auction"
"['open_auction', 'close_auction']"

Upvotes: 1

Views: 6245

Answers (2)

Serge Basile
Serge Basile

Reputation: 11

This is probably outdated, but pusher has a channel.bind_global that would allow you to listen to all events sent to that channel. Docs: https://pusher.com/docs/channels/using_channels/events/#example-3

Upvotes: 1

Robin Hawkes
Robin Hawkes

Reputation: 708

You can only bind to a single event so you'd either need to manually define each listener or store an array of events and loop through them (creating a new listener each time). Check out the answer here for more information: Pusher: How to bind to 100s of events?

Upvotes: 5

Related Questions