goatslacker / alt

Isomorphic flux implementation
http://alt.js.org/
3.45k stars 323 forks source link

Using waitFor on an alt instance with child instances. #698

Closed special-character closed 2 years ago

special-character commented 7 years ago

Would it be possible to waitFor a child instance to complete a dispatch before calling a new action in the parent instance? I read that each alt instance has their own dispatcher (188) and when I tried to waitFor a child instance dispatch to complete, my parent's dispatcher could not see those dispatches. The structure I have is similar to ##issue: 118.

EX:

// pseudo-code
class ParentStore {
    onParentAction() {
        const toWait = [];
        _.forEach(childFluxes, (altInstance) => {
            toWait.push(altInstance.stores.ChildStore);
        });
        this.waitFor(toWait);
        // do ParentStore stuff
    }  
}

In this case toWait has the correct child stores to wait for but the parent's dispatcher doesn't have them registered and cannot see anything being dispatched.