gabrielpoca/meteor-redux-demo

Best practice to handle loading spinner using Tracker?

Closed this issue · 2 comments

I'm unsure how to handle a loading spinner. Is it possible with your tracker-based implementation?

import { Tracker } from 'meteor/tracker';
import { createStore, applyMiddleware } from 'redux';
import thunk from 'redux-thunk';

import reducers from '../reducers/reducers';
import Messages from '../../lib/messages';

export default () => {
  const store = createStore(reducers, applyMiddleware(thunk));

  Tracker.autorun(() => {
    store.dispatch({ type: 'SET_LOADING_TRUE', payload: {} });
    store.dispatch({ type: 'SET_MESSAGES', messages: Messages.find().fetch()});
    // where can I set loading false? store.dispatch({ type: 'SET_LOADING_FALSE', payload: {} });
  });

  return store;
};

I apologize. I see it is built into the SubscribeComponent-- and nicely done.

@acomito I just realized that my solution doesn't work, I'll update and notify you. Sorry for the inconvenience.