Giter VIP home page Giter VIP logo

Comments (5)

arunoda avatar arunoda commented on August 21, 2024

How does this relates to meteor-streams?

This might help you anyway.

from meteor-streams.

zeroasterisk avatar zeroasterisk commented on August 21, 2024

(sry - I accidentally submitted the question too early - just edited)

from meteor-streams.

arunoda avatar arunoda commented on August 21, 2024

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.

zeroasterisk avatar zeroasterisk commented on August 21, 2024

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.

arunoda avatar arunoda commented on August 21, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.