ground-db
ground-db copied to clipboard
Change in Template level autorun behaviour
I encountered some problems with the newest ground:db version related to the dispatch:kernel package (which was introduced in v0.3.9). This package causes template.autorun() to rerun after the view is already destroyed! That is causing various problems in our project, especially with autoform and some own components.
Thanks, bugger - this would be nice to work out. Can you give an example of the autorun and where it's initialized?
@gandev just made a fix for this - can you try updating using dispatch:[email protected]
and see if the issue goes away?
We forked ground:db and removed the kernel call for the moment. But with your fix in place one of the resulting problems (which was easily reproducible) disappeared. I will test some more when the time permits, thank you.
I do have a similar problem (tell me if it is not, I'll open another issue). Every template level autorun triggers the following error:
Exception from Tracker afterFlush function:
Error: Can't call View#autorun from a Tracker Computation; try calling it from the created or rendered callback
The default dispatch:kernel
module version is 0.0.6
Here is a minimal example of the code triggering this error:
Template.Example.rendered = function() {
self=this;
self.autorun(function(){ //faulty line
console.log (myReactiveVar.get());
})
}
Similar problem for me. @gandev's solution works fine
@raix with grounddb v2 I still have the same problem.
Template.flowCharting.onRendered(function () {
$('select').material_select();
$container = $('#container');
window.addEventListener('resize', _.debounce(() => jsPlumb.revalidate($('.rect')), 300));
this.autorun(function () {
jsPlumb.ready(function () {
jsPlumb.setContainer('container');
const source = Template.currentData();
const data = (source instanceof ReactiveVar) ? source.get() : source;
clearCharting();
if (data) {
rectsRestore(data);
if (data.userData) rectsRestore(data.userData, true);
}
});
this.autorun(function () {
const source = Template.currentData();
const data = (source instanceof ReactiveVar) ? source.get() : source;
containerEditable();
if (data) {
if (isModifiable.get()) everyRectsEditable();
else rectsNotEditable();
}
});
});
});
Error: Can't call View#autorun from a Tracker Computation; try calling it from the created or rendered callback
at Blaze.View.autorun (dispatch_kernel.js?hash=0b93ecb…:338)
at .<anonymous> (flowCharting.js:59)
at dispatch_kernel.js?hash=0b93ecb…:344
at Object.Blaze._withCurrentView (blaze.js?hash=a9372ce…:2214)
at viewAutorun (dispatch_kernel.js?hash=0b93ecb…:343)
at KernelComputation (dispatch_kernel.js?hash=0b93ecb…:295)
at Tracker.Computation._compute (tracker.js?hash=f525263…:339)
at new Tracker.Computation (tracker.js?hash=f525263…:229)
at Object.Tracker.autorun (tracker.js?hash=f525263…:604)
at Object.Kernel.autorun (dispatch_kernel.js?hash=0b93ecb…:292)
Is that related to ground:db ???
@NitroBAY it's a shame - I'm thinking we might have to take out the dispatch:kernel... This might hurt performance though.
I have this bug since months and became half crazy, had to use Tracker.autorun() but it has other problems, I didn't know it was related since today and didn't understand why I was the only one who had this bug. Please explain me how the heck no one has ever noticed that this.autorun() oftenly doesn't work when one has ground:db ??
In any way I will be glad you remove it ASAP (to maybe reintroduce it later on ?)