Skip to content

@Dispatch ​

@Dispatch dispatches whatever the decorated method returns, and returns it to the caller as well. A return value of false skips the dispatch.

ts
import { Dispatch } from '@angular-redux2/store';

export class TodoComponent {
    @Dispatch
    add(title: string) {
        return { type: 'ADD_TODO', payload: { title } };
    }
}

It is applied without parentheses, and works on arrow-function properties too. The action goes to the class's sub-store when it has one, otherwise to NgRedux.store.

See also ​

Released under the Mozilla Public License 2.0