@msavin I’d love it if you discussed more how we can hide Tracker? You kinda lost me there.
My conclusions have been that if you “hide tracker” and perhaps use it to power Redux and an app which uses only unidirectional data-flow, then you might as well just get rid of Tracker. And that’s a very solid option. In fact, my research has led me to the conclusion that the best part of Tracker is in fact just the mongo style interface in your helper methods!
So one path is providing an interface within your component methods that mirror minimongo like this this.posts.insert({})
and this.posts.find(selector, options)
but behind the scenes trigger Redux actions and intersect data placed in component props via Redux ;). And of course, Relay is likely a better backer than Redux.
THIS MAY MAKE IT MORE CLEAR:
class MyComponent extends React.Component {
allPosts() {
//notice how here we are not doing `Posts.find()
//this is because Redux (or Relay) already populated props with them
//and we are just extracting them from props under the hood
return this.posts.find();
}
changeTitle(id) {
//again, notice the usage of `this`
//that lets us wire everything up to Redux or Relay behind the scenes while
//keeping an identical interface to what the Meteor user is familiar with
this.posts.update(id, {$set: {title: prompt()}});
}
render() {
return (
<div>
{this.allPosts.map(post =>
<h1 onClick={this.changeTitle.bind(this, post._id)}>
{post.title}
</h1>
)}
</div>
);
}
}
From a Meteor developer’s standpoint, it’s almost identical to how they currently use Minimongo as part of the Transparent Reactive Programming scheme Blaze uses. But the way the data flows, is standard unidirectional Redux stuff. So that’s my conclusion of how we best “hide” tracker, which is basically getting rid of it, but keeping the best part, which is the Mongo finder interface. Oh, and actions are automatically generated for insert
, update
, etc, which result in your data stored in your Redux store, but look like standard collection methods.
The other options I see is to enhance tracker so it re-runs your functions less, and just use it part of Tracker React and call it a day. …Well, I’m kinda kidding. Basically we need to put a new “shine” on tracker so it feels as trustworthy as React + Redux. And by “shine” i mean build some truly solid tools that make Tracker-based apps debuggable. Some of examples of tool sthat would provide that are:
- traveling for mini mongo and reactive dict
- reactive dependency visualizations (i.e. like this for Rx: http://jaredforsyth.com/rxvision/)
- specific tools for unit testing functions that utilize reactive data sources (i.e. automatic fixture generation tools for the data in your collections and ReactiveDicts so you can test the inputs of functions almost as easily as you do for pure functions)
I think if we can make Tracker style Transparent Reactive Programming feel as trustworthy as the unidirectional forceUpdate
stuff then we may have something the industry will respect up our sleeves. As Tracker currently is, we get no respect in the greater JS/NPM ecosystem. So we gotta lock these things down, and then position it as an option that plugs in nicely alongside the unidirectional stuff within React, just as Mobservable and TrackerReact do.