From 4fe3672b6f9e077424a708bda62c0572658cc5b1 Mon Sep 17 00:00:00 2001 From: Max Nowack Date: Mon, 18 Jul 2016 14:09:52 +0200 Subject: [PATCH] return computation in this.autorun `this.__comps.push` return the index of the pushed element. `Tracker.autorun` and `this.autorun` in Blaze return the computation. I think that was tried to achieve with 07400b29e86ff1f5efb1bb07aca889f195778a7d --- lib/index.jsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/index.jsx b/lib/index.jsx index 1ffb799..c8a3ff6 100644 --- a/lib/index.jsx +++ b/lib/index.jsx @@ -15,9 +15,13 @@ Tracker.Component = class extends React.Component { this.__subscribe.apply(this, [name, ...options]); } - autorun(fn) { return this.__comps.push(Tracker.autorun(c => { - this.__live = true; fn(c); this.__live = false; - }))} + autorun(fn) { + const computation = Tracker.autorun(c => { + this.__live = true; fn(c); this.__live = false; + }) + this.__comps.push(computation) + return computation + } componentDidUpdate() { !this.__live && this.__comps.forEach(c => { c.invalidated = c.stopped = false; !c.invalidate();