DispatchMe / meteor-kernel

Run reactivity in request animation frame for performance
MIT License
20 stars 7 forks source link

This.autorun() doesn't work #6

Open ilan-schemoul opened 8 years ago

ilan-schemoul commented 8 years ago

See https://github.com/GroundMeteor/db/issues/101

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)
ilan-schemoul commented 8 years ago

Note that I have this package because of ground:db (V2 RC5) and that I never wanted him to mess with my project, if you want to use it in your project I do understand but installing ground:db shouldn't have side effect as installing a package which messes with Meteor.