I\'m using alt as my flux implementation for a project and am having trouble wrapping my head around the best way to handle loading stores for two related entities. I\'m usi
The best solution I've come with with so far (and the one that the examples seem to follow) is to add a "jobsFetched" action to my jobs actions and to dispatch it when the data arrives.
var jobActions = require('../actions/Jobs');
var ConversationActions = require('../actions/Conversations');
class JobStore {
constructor() {
this.bindListeners({
handlefullUpdate: jobActions.success...
});...
}
handlefullUpdate(jobs) {
this.jobs = jobs;
ConversationActions.jobsFetched.defer(jobs);
}
}
class ConversationStore {
constructor() {
this.bindListeners({
handleJobUpdate: jobActions.jobsFetched...
});...
}
handleJobUpdate(jobs) {
/*Now kick off some other action like "fetchConversations"
or do the ajax call right here?*/
}
}
This eliminates the problem of the jobs store having to hold a reference to all its dependent objects, But I still have to call an action from inside my store, and I have to introduce jobsFetched action which sets up the ConversationStore to fetch it's data. So it seems like I can't use a source for my conversations.
Can anyone do better?