Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save acodesmith/6b0dbfb5b251bd4883fae0f5afa1524c to your computer and use it in GitHub Desktop.
Save acodesmith/6b0dbfb5b251bd4883fae0f5afa1524c to your computer and use it in GitHub Desktop.
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))
})
@deanrad
Copy link

deanrad commented May 16, 2016

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

@acodesmith
Copy link
Author

Thanks for the tip, much better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment