Global reactive object?

I’d like to be able to display an alert on all connected clients when my server is having trouble accessing an external API. Is there a way to register a single javascript object that can be referenced reactively by client-side templates? I could use a collection that holds just a single entry but that doesn’t seem quite right. I’ve looked at ReactiveVars but they seem to be just client-side. Any other options?

Thanks a lot!

Personally, I think using collection is the fiine. Later you might need other messages passing through. So a collection can serve that purpose. :smile:

1 Like

If you want to notify all connected clients, you can implement a publish() method using null as the name.

See also here.

The data published can come from a collection (typically CollectionName.find(...)), or you can generate publication data yourself in the publish() method by using this.added(), this.changed(), this.removed() and this.ready().