"Deep Tracker Integration" for React Today!

I can probably just show you what the issue was pretty quickly, hopefully it makes sense:

If you had something like

A = React.createClass({
  helper(arg) {
    if (arg) {
      return Session.get('a');
    } else {
      return Session.get('b');
    }
  },
  render() {
    return <div>{this.helper(true)} {this.helper(false)}</div>;
  }
}

Then if you did Session.set('a', 'x') it would not re-render, as the autorun that depended on Session.get('a') would have been destroyed in setting up the autorun the second time (to depend on Session.get('b')).

Duh! Can’t believe I missed that. …well luckily on this one, the [final] solution was also the clearest and most natural.

I guess the problem is that even if that existed, we can’t rely on users (e.g. package authors like in the case I was quoting in the bug, where it was FlowRouter calling Tracker.flush()) calling React.flush() – I mean why would they when writing a package that’s not relevant to React?

I think the real answer here is that Tracker.flush() is a bad idea unfortunately, as @dgreensp concluded. All we can do now is deprecate it in future versions of Meteor.

i mean you couldn’t even use any helper multiple times if it didn’t have the same arguments. wow.

The vision for all this would likely involve overwriting Tracker.flush/afterFlush to call the React implementations if React is detected as the renderer.

Hi,

I’ve just discovered this package this morning. I was extremely confused at first since the description in the initial (and veeeeeery long) post concerning functions starting with underscores etc didn’t seem to match the code. However, having now read these comments I see that it’s since evolved considerably.

In any case, the current implementation is simply excellent. This is a much nicer solution than the official mixin and it’s really fantastic to have such natural Meteor-based reactively so tightly integrated into a Blaze component. Well done.

5 Likes

i know there are alot of issues for now, this approach is so much nicer than ReactMeteorData mixin.

1 Like

Ya, this is a very nice step in the right direction. ReactMeteorData required too much manual connecting than normal Blaze and Meteor that we are all used to. Good stuff!

1 Like