-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optimization: customize the publish/subscribe methods #14
Comments
How does this relates to meteor-streams? This might help you anyway. |
(sry - I accidentally submitted the question too early - just edited) |
Hope this would work. Notifications = Meteor.Streams('notifications');
if(Meteor.isClient) {
Notifications.emit('active', true);
}
if(Meteor.isServer) {
var states = {};
Notifications.on('active', function(state) {
states[this.subscriptionId] = state;
this.onDisconnect = function() {
delete states[this.subscriptionId]
};
});
Notifications.permissions.read(function() {
return !!states[this.subscriptionId];
}, false);
} Anyway, we need a better and simple easy way to do this. I will add a new API. But not sure about the timeline. |
SWEET! thanks for the plugin, thanks for helping me, and thanks for the ninja-fast response. As I read this
is that correct? BrainstormingIf mine is an edge case, this should be a sufficient workaround. The concept of "listening = true/false" seems like a simple enough one to implement (perhaps a slightly cleaner implementation than your above code, but functionally the same). It isn't as versatile/direct as customizing the publish/subscribe, but it is a heck of a lot easier and simpler. If you think customizing the publish/subscribe "rules" for notifications is a common enough use case, perhaps you could provide default publish/subscribe, allowing developers to manually assign if they had custom rules. (?) Or maybe you could look for a |
Yes you are correct. You've to do allow write permissions also. If Notifications.permissions.read(function() {
return true
}); Your suggestion on the API is good. I'll consider it 👍 |
Is there some way we could customize the publish/subscribe methods for the collection?
In my use case, I only need to monitor messages dependant on a Session variable.
That is, 95% of my clients don't care at all, and wont render/act upon any notifications.
Were this a normal publish/subscribe, I could base the subscribe upon the Session variables.
While the code runs fine, with the Session variable restrictions being handled in the
on()
handler, it's not optimal. All clients are getting all messagesAnd yes, I know I can restrict based on the
Meteor.userId
but in the case of this app, most clients are anon.The text was updated successfully, but these errors were encountered: