Hi,
it’s not easy to give good advice based on your relatively vague explanation of what you’re doing exactly.
But from my point of view, using a “reactive var” in this situation might actually not be the best way.
I’d implement the popup so it could receive some data as arguments for the rendered template inside it. I’m sure if you look on atmosphere you could find some examples or actual implementations you could use.
Then I’d probably open the “popup”, however you implement it, from inside the result callback of the method call (where you now have the reactiveVar.set()
call). Why not open it from there and pass the data through at the same time? Then you don’t have to open a popup first and then push the data through another channel, in that case a reactive var.
If you want to go the reactive var route, The way I’d do it is thus:
- in the eg.
myPopupTemplate.js
file containing the template-code (helpers, events etc) for your popup-template, I’d export a reactive var, eg:
(Note: I’ve used this forever, so I am not sure, maybe you need to add the ReactiveVar - package to your project, have a look at atmosphere, again, please)
export const popupData = new ReactiveVar()
(you can add a default value in the () brackets if you like)
Then you can import this reactiveVar from your file with the method call like this:
import { popupData } from '/path/to/myPopupTemplate.js'
And then you could add a template helper to your myPopupTemplate.js
:
Template.myPopupTemplate.helpers({
getPopupData() {
return popupData.get()
}
})
-> And then you’d have a cool reactive template helper.
But I think this isn’t actually the best way, because you’d need to trigger the opening and closing of the popup as well etc.