Meteor and AngularJS reactive subscriptions

Flavien Volken

I've a publication which relies on a client's parameter. Therefore, while subscribing from the client I need to send this parameter to the server. I'm using the angular-meteor package and found the $subscribe wrapper. The usage is as follow: $subscribe.subscribe(name, publisherArguments) I am trying to pass dynamic $scope values to the subscription but it does not seems to work. For example the following example never alerts "You subscribed !"

   $subscribe.subscribe('aPublication',$scope.parameter).then(function(){
         alert("You subscribed !");
  });

assuming the server side looks like this

  Meteor.publish("aPublication", function (parameter) {
    ACollection.find({'aProperty':'parameter'}) });

What should I do to make the $scope.parameter works the same way as if I was using Session.get('parameter') ?

Urigo

@Flavien Volken, that's a really nice solution but in our new 0.6.0 version you can also do it with a solution a bit more similar to the Meteor way using scope.getReactively - http://angularjs.meteor.com/api/getReactively

So in your solution:

$meteorUtils.autorun($scope, function() {      
   $meteorSubscribe.subscribe('aPublication',
                              $scope.getReactively('parameter'))
                             .then(function(){
                                  alert("You subscribed !");
      });
});

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Meteor and AngularJS reactive subscriptions

From Dev

Are non-reactive Meteor db subscriptions possible?

From Dev

Selecting active Meteor Subscriptions

From Dev

Meteor Subscriptions ready not working

From Dev

Selecting active Meteor Subscriptions

From Dev

How to force Meteor to reload subscriptions?

From Dev

Meteor publications/subscriptions not working as expected

From Dev

right way to use subscriptions in meteor

From Dev

Stopping Meteor autorun in template subscriptions?

From Dev

Meteor publications/subscriptions not working as expected

From Dev

Meteor: reactive: false not working

From Dev

JQuery and Reactive Meteor Components

From Dev

Meteor publish subscribe is not reactive

From Dev

Making tooltips reactive in Meteor

From Dev

Making if Statement reactive in Meteor

From Dev

meteor deps not reactive

From Dev

Meteor progressbar for template subscriptions with actual progress

From Dev

How can I make Meteor subscriptions dynamic?

From Dev

Where Should Meteor Subscriptions Be Located in My Application?

From Dev

Where Should Meteor Subscriptions Be Located in My Application?

From Dev

How to access FlowRouter subscriptions in Meteor template helpers?

From Dev

Meteor subscriptions are not stopping after changing Ionic views

From Dev

Is it necessary to stop subscribing in helper level subscriptions with Meteor?

From Dev

Reactive joins in Meteor - best practice?

From Dev

Meteor JS $near Reactive Sorting

From Dev

Making Meteor reactive for html elements

From Dev

Meteor reactive function for Template updates

From Dev

Meteor - Template.currentData() not reactive?

From Dev

Meteor :read Session keys and be reactive

Related Related

HotTag

Archive