Comments (5)
How does this relates to meteor-streams?
This might help you anyway.
from meteor-streams.
(sry - I accidentally submitted the question too early - just edited)
from meteor-streams.
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.
from meteor-streams.
SWEET! thanks for the plugin, thanks for helping me, and thanks for the ninja-fast response.
As I read this
- no client would be "subscribed" (no messages sent on) until it had sent through the
.emit('active', true);
- and once that has happened, other messages would be passed like normal like
.emit('sent', 'yup this is sent');
- until
.emit('active', false);
is sent in by this client
is that correct?
Brainstorming
If 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 streams.subscribe()
method, which could be run on the client to determine if it should subscribe. (?)
from meteor-streams.
Yes you are correct. You've to do allow write permissions also. If emited
from a client
Notifications.permissions.read(function() {
return true
});
Your suggestion on the API is good. I'll consider it 👍
I'm thinking about new easy to understand API. I'll publish more info as I go through it.
from meteor-streams.
Related Issues (20)
- Need updated for 0.9.0 HOT 25
- How does one use streams for server to server communication?
- client2client, WRTC, p2p ? HOT 2
- Connect to Meteor Stream Externally
- Git push? HOT 2
- Target a specific client from the server.
- Can a server listen to a stream in another server? HOT 1
- Still alive? HOT 2
- Streaming Video Camera HOT 1
- Additional parameters is null in read permissions HOT 4
- Feature HOT 1
- Minor typo in html documentation HOT 2
- It does not work inside a method
- send frequent data to clients HOT 1
- Streams not working until page refreshed
- emit not working - not emiting to all clients and Random is not defined. HOT 5
- Your app is crashing. Here's the latest log. HOT 1
- i have failed to add meteor streams to my project
- Possiblity breaking changes in new Meteor version HOT 3
- The package doesn't work on Meteor 1.3.3 or later. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from meteor-streams.