我有一个案例,在使用角度流星的Meteor应用程序中很少有用户在页面(ui-router状态)上。我想在每次用户执行操作时为所有用户显示toast ,这是对集合的更新。
我想为此我应该在收集更新的那一刻从服务器触发吐司,但由于它是CSS和客户端的东西,我无法弄清楚如何做到这一点。
有没有办法在集合上实现一些监听器,并告诉它何时通过Toast更新到当前处于特定状态(页面)的所有用户?
答案 0 :(得分:1)
您必须创建一个通知集合,为每个操作插入每个用户的通知。您还需要一个仅订阅当前用户通知的通知pub / sub。然后,在模板助手中:
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.
}
}