简体   繁体   中英

Server-side triggered toast in Meteor

I have a case where few users are on a page (ui-router state) in a Meteor app using angular-meteor. I want to make a toast appear for all the users each time a user performs an action, which is an update for a collection.

I guess that for this I should trigger the toast from the server the moment the collection get updated, but since it's a CSS and client thing I can't figure out how to do it.

Is there a way to implement some listener on a collection and tell whenever it gets updated by a toast to all the users that are currently on a specific state (page)?

You'd have to create a notifications collection that inserts a notification for each user for each action. You'll also need a notifications pub/sub that subscribes to only the current user's notifications. Then, in your template helpers:

notifications() {
    var notification = Notifications.findOne();
    if( notification ) {
      // Execute a modal popup or something - make sure to pass the current value.
      // Call a meteor method to remove the notification.
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM