Skip to content

When using batch, do not receive error when calling dispatch inside of dispatch #225

@wrightnathan

Description

@wrightnathan

The following code will not throw an error in console:

in my componentDidMount():

Reactor.batch(() => {
    Reactor.dispatch('DISPATCH1');
})

in my store:

initialize() { 
    this.on('DISPATCH1', (state) => {
        Reactor.dispatch('DISPATCH2');
        return state;
    });
    this.on('DISPATCH2', (state) => { return state.set('blah', foo);} );
}

This will execute DISPATCH2 inside of DISPATCH1, but will result in the changes made by DISPATCH2 being thrown away (instead of receiving an error message).

If I remove the batch, then I receive the following error message:

nuclear.js:5647Uncaught Error: Dispatch may not be called while a dispatch is in progress

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions