MantraJS retrieve data from actions

Is there any way of retrieving data from actions, which calls and retrieves data from Meteor methods?


as with any flux-like architecture, your actions should change some kind of state. in mantra / meteor the state is usually in minimongo-collections or in LocalState (a reactive dictionary).

so your methods can return data, but you would usually store that into localState or in a meteor-collection.

if you want to bypass this principle, you can have your action receive a callback-function. The action then calls the method and passes the result to the passed callback-function.

@macrozone thank you for your reply.
I am trying to follow that principle and storing my data into LocalState as below:

 applyFilter({Meteor, LocalState,FlowRouter},survey_id,filter){'_answers.getAggregateData',survey_id,filter,(error,responce)=>{

                return LocalState.set('graph_data',responce);

And reading that data from LocalState in my composer. But I am not able to access this data in my component.
Below is my composer.

import {useDeps} from 'react-simple-di';
import {composeWithTracker, composeAll} from 'react-komposer';

export const composer = ({context, clearErrors,permission_denied,_id}, onData) => {
  const {Meteor, Collections, LocalState} = context();
  const error = LocalState.get('SURVEY_ERROR');
  const loggedIn = Meteor.user();
  const graph_data=LocalState.get('graph_data');
  if (Meteor.subscribe('_surveys.single',_id).ready()) {
      const survey = Collections.surveys.findOne({_id:_id});
      const answerCount = survey.answerCount;'_answers.getAggregateData',_id,null,(error,responce) => {
      if ( error ) {
        Bert.alert( error.reason );
      } else {
       for(var i=0;i<responce.length;i++){
       onData(null, {responce,answerCount,survey,graph_data});  
  return clearErrors;

export const depsMapper = (context, actions) => ({
  clearErrors: actions._survey.clearErrors,
  applyFilter: actions._survey.applyFilter,
  permission_denied: actions._survey.permissionDenied,
  context: () => context

export default (component) => composeAll(

What am I missing?


in your composer you now also call the meteor-method, is that intended?

also log what graph_data is when you call your action (with the method).

does it change? Maybe add debugger statements.

Yes it is because aggregate function in mongo is not reactive, so I am achieving it through methods.
In actions I am calling same method but with some filters. As a result I would like to render same component with different data.

According to my logs graph_data is being set in first click but component is getting data in next click. I can not understand why it is happening so.