Created
May 15, 2016 23:09
-
-
Save acodesmith/6b0dbfb5b251bd4883fae0f5afa1524c to your computer and use it in GitHub Desktop.
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
Template.restaurant.onCreated(function() { | |
let restaurantSub = this.subscribe( 'Restaurant', [ FlowRouter.getParam('restaurantId') ] ) | |
, restaurantPromise = restaurantSub.readyPromise() | |
this.restaurant = new ReactiveVar() | |
this.ready = new ReactiveVar( false ) | |
restaurantPromise.then(function(){ | |
this.restaurant.set( Restaurant.findOne() ) | |
this.ready.set( true ) | |
}.bind(this)) | |
}) |
Thanks for the tip, much better!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Cool! Pretty much just how I pictured it, though I'd maybe have moved the template ivar creation to be the most prominent, and inlined the promise.
https://gist.github.com/deanius/e7fea266dbfa4c9097b3eb733bdb6f04