Container query - react-komposer


#1

Hello,

I was reading this article, and it is all quite interesting. Still not at point where want to dip toes into graphql, but thats an aside. The article references, “A quick glance will show you that it’s asking for the info from each container serially. We saw this and immediately realized that the query execution process should be parallelized.

So this is quite interesting. Totally legit. Looking at one of my containers…

import { Meteor } from 'meteor/meteor';
import { composeAll, composeWithTracker } from 'react-komposer';
import { Loading } from '../components/utility/loading.js';

import { ls } from '../../api/ls/ls.js';
import { tSetups } from '../../api/tSetups/tSetups.js';

import { Entities } from '../../api/entities/entities.js';
import { Libs } from '../../api/libs/libs.js';

import { DocTemplates } from '../../api/docTemplates/docTemplates.js';
import { Docs } from '../../api/docs/docs.js';

// Inject into here...
// import { User } from '../components/user/user.js';
import { Home } from '../components/user/home.js';

const composerL = (params, onData) => {
  const subscription = Meteor.subscribe('user.ls');
  if (subscription.ready()) {
    const ls = ls.find().fetch();
    onData(null, { ls });
  }
};

const composerTS = (params, onData) => {
  const subscription = Meteor.subscribe('user.tSetups');
  if (subscription.ready()) {
    const tSetups = tSetups.find().fetch();
    onData(null, { tSetups });
  }
};

. // code removed for brevity
.
.
.

const composerUser = (params, onData) => {
  onData(null, { user: Meteor.user() });
};

export default composeAll(
  composeWithTracker(composerL, Loading, null, { pure: false }),
  composeWithTracker(composerTS, Loading, null, { pure: false }),
  composeWithTracker(composerEntities, Loading, null, { pure: false }),
  composeWithTracker(composerLibs, Loading, null, { pure: false }),
  composeWithTracker(composerUsers, Loading, null, { pure: false }),
  composeWithTracker(composerDocTemplates, Loading, null, { pure: false }),
  composeWithTracker(composerDocs, Loading, null, { pure: false }),
  composeWithTracker(composerUser, Loading, null, { pure: false }),
)(Home);

Presumably the bit at the end is what we are talking about. Is this serialized or parallelized? Should I be trying to use promises to handle the loading of all these containers nicely? explanations with examples appreciated as am noob.

As an aside, has anyone successfully moved to react-komposer 2 or is the peanut gallery opinion to ditch it and move to create-container as anything ex-kadira is now suspect? I’ma big fan of a lot of arunoda’s work, but it is what it is right.

Thanks so much.

Tat