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)