0

I am trying to build a Pusher-driven app (Angular + node.js). I am holding an in-memory db (array of objects that are subject to CRUD). What would be the good practice to send the list of objects/ids to a new user?

Say, I have initialization in server.js (node)

let pusher = new Pusher({
  appId: process.env.PUSHER_APP_ID,
  key: process.env.PUSHER_APP_KEY,
  secret: process.env.PUSHER_APP_SECRET,
  encrypted: process.env.PUSHER_APP_SECURE === 1,
  cluster: process.env.PUSHER_APP_CLUSTER,
});

pusher... // `connection` doesn't exist here yet

So, the question can basically be rephrased to: what is the equivalent of socket.io's

io.on('connection', socket => {
  // send objects here
});
user776686
  • 7,933
  • 14
  • 71
  • 124

1 Answers1

0

Not sure I understand 100% your question, but...

I think there is no way to do exactly what you want like in socketIO, from the server (because you don't own the server). But you could set up webhooks for channels, or maybe use presence channels. I would start looking around from there.

But maybe you can make each client ask for the data after subscription to a channel as explained here: https://pusher.com/docs/channels/using_channels/events#binding-on-the-client the event you would be interested in is pusher:subscription_succeeded.

LucasMetal
  • 1,323
  • 10
  • 16