Interface ClientNotificationCallbackArgs<TState, TAction>

Contract for set of arguments that are passed back from state container to the callback function when action got dispatched and/or reducer executed (state changed).

Type Parameters

  • TState extends Object

  • TAction extends Action

Hierarchy

  • ClientNotificationCallbackArgs

Properties

action: TAction
changedPaths: (keyof TState)[]

List of state attributes that got changed. This name is, however, reserved for future extensions.

Please note state container only detects changes made to the top-level attributes. And, which is important, you need to create (return in the reducer function) a new state object (sorry, no immer.js-like magic here, at least for now).

Let's take as an example simple state of an electric vehicle:

Object ("EV")
+- "power" (object)
| +- "currentConsumption" (number)
| +- "rangeLeft" (number)
+- "wheels" (array)
+- "frontLeftPressure" (number)
+- "frontRightPressure" (number)
+- "backLeftPressure" (number)
+- "backRightPressure" (number)

If there is a state change due to invoking accelerateReducer() function, that, in effect, modifies changes both the currentConsumption (in kWh) and rangeLeft attributes, the attributes that got changed would be ["power"] (not ["power.currentConsumption", "power.rangeLeft"]).

Please note: [] got returned when action made no effect to the state or the bypassReducer was true

newState: TState
oldState: TState

Generated using TypeDoc