Dispatch(target: any, functionName: string | number | symbol, descriptor?: PropertyDescriptor): any
Decorator that automatically dispatches the return value of a decorated function
to the Redux store using ngRedux.dispatch().
// These dispatches will be scoped to the substore as well, as if you // had called ngRedux.configureSubStore(...).dispatch(numLines).
@Dispatch addCode(numLines: any) { // Dispatching from the sub-store ensures this component instance's // subStore only sees the 'ADD_LOC' action. return { type:'ADD_LOC', payload:numLines }; }
In the above example, the addCode function is decorated with @Dispatch.
Anytime the addCode function is called, its return value will automatically
be dispatched to the Redux store using ngRedux.dispatch().
Remarks
This decorator assumes that the component instance has an ngRedux property
that refers to a valid NgRedux instance. If the component instance does not
have an ngRedux property, an error will be thrown.
Decorator that automatically dispatches the return value of a decorated function to the Redux store using
ngRedux.dispatch()
.In the above example, the
addCode
function is decorated with@Dispatch
. Anytime theaddCode
function is called, its return value will automatically be dispatched to the Redux store usingngRedux.dispatch()
.Remarks
This decorator assumes that the component instance has an
ngRedux
property that refers to a validNgRedux
instance. If the component instance does not have anngRedux
property, an error will be thrown.Returns
The PropertyDescriptor.