Last active
August 29, 2015 14:05
-
-
Save zefei/aa8721ff95affe0c253b to your computer and use it in GitHub Desktop.
Example of using Meteor reactivity inside Angular: using Meteor sessions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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