payloadvalue and attaches the returned action, call the
withPayload(), action creators returned by
createAction()have the following properties:
type: The type value passed to
createAction(). Removes the need for a separate action type constant, and allows other helpers such as
onActionto inspect the
typevalue of the produced actions at runtime.
matches(action): A method that returns true the the passed action has the same
typeas the ones produced by the action creator.
.withPayload()is defined with a type parameter that specifies the payload type. You can override the default (
any) by specifying the type parameter explicitly:
.matches()is defined as a type predicate. Using it in a condition allows the TypeScript compiler to narrow the type of passed action to the specific type of action returned by the action creator: