Skip to content

Instantly share code, notes, and snippets.

@zefei
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zefei/aa8721ff95affe0c253b to your computer and use it in GitHub Desktop.
Save zefei/aa8721ff95affe0c253b to your computer and use it in GitHub Desktop.
Example of using Meteor reactivity inside Angular: using Meteor sessions
// a reactive block that depends on a collection (Products)
// and a session value
autorun($scope, function() {
Meteor.subscribe('products');
var myCity = Session.get('myCity');
$scope.products = updateCollection(Products.find({city: myCity}).fetch(), $scope.products);
});
...
// any of following lines will trigger the reactive block above
Products.insert({name: 'Coke', city: 'LA'});
Session.set('myCity', 'Shanghai');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment