Subscribe in redux-thunk action creator
rgstephens opened this issue · comments
Greg Stephens commented
I'd to keep the my Meteor interactions in a redux action creator using redux-thunk. Using Meteor.ddp.on("added"...
, I can see that the data is being retrieved but the Meteor.collection('keys').find()
returns null.
I suspect this is because the call is not wrapped in createContainer but I don't want to do the updates in a React component. Is it possible to maintain a redux store with Meteor data in this way?
export const getKeys = () => {
const keysSubscription = Meteor.subscribe('keys');
Meteor.subscribe("keys", {
onReady: function () {
console.log('Meteor subscribe ready!');
const keys = Meteor.collection('keys').find();
console.log('Meteor keys: ', keys);
return (dispatch, getState) => {
dispatch({
type: 'GET_KEYS',
keys: keys
});
}
},
onStop: function () {
console.log("Meteor onStop: ", arguments);
}
});
}
Greg Stephens commented
There was a problem with the server publication.