React-komposer, composer functions that depend on prop provided by other composer functions

Hello I’m trying to compose composer functions that depends on props provided by other composer functions.

This one provides prop called a.

import {useDeps, composeWithTracker, composeAll} from 'mantra-core';
import Component from '../components/component';

export const composerA = ({context, _id}, onData) => {
  const {Meteor,Collections} = context();
  const query = {_id};
  if (Meteor.subscribe('a', query).ready()) {
    const a = Collections.A.findOne(query);
    onData(null,{a});
  }
};

This one depends on prop called a.

// depends on `prop` named `a` which is provided  by `composerA`
export const composerB = ({context, a}, onData) => {
  const {Meteor,Collections} = contex()t;
  if(a){
    const query = {a_id : a._id};
    if (Meteor.subscribe('b', query).ready()) {
      const bs = Collections.B.find(query);
      onData(null,{bs});
    }
  }
};

When there’s no dependency, it works fine.

export const ThisWorks = compoaseAll(
  composeWithTracker(composerA),
  // some other composer function without dependency 
  composeWithTracker(composerWithoutDependency)
)(Component);

But when I compose it with composerB which depends on A it loads/waits forever.

export const ThisLoadsForever = compoaseAll(
  composeWithTracker(composerA),
  composeWithTracker(composerB)
)(Component);

I suspect that prop a never becomes available or not null to composerB, hence waiting/loading forever. How do I fix this? Or is there other way to compose composers with dependency?

SO link [here] ( http://stackoverflow.com/questions/36519195/react-komposer-composer-functions-that-depend-on-prop-provided-by-other-compose)

I think the problem is that you need to pass a loading page when the condition if (a) is false. Compose works like compose(a, b)© is a(b©). Now your if (a) won’t be satisfied the first time. But this should not cause forever loading. May be I am wrong but try adding a onData(null, Loading) if your condition if(a) fails.

I think debugging would be your best bet. Mantra is designed so that debugging these issues is easy as all your data bringing code is separate from your components.