简体   繁体   English

流星中的服务器端触发吐司

[英]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. 我遇到的情况是,使用angular-meteor的Meteor应用程序中的页面(UI路由器状态)上的用户很少。 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. 我想为此,我应该在集合更新后立即从服务器触发敬酒,但是由于这是CSS和客户端程序,所以我不知道该怎么做。

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.
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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