Listening to AdapTable State

View as Markdown

Summary

  • The AdapTable State Changed Event fires whenever anything changes in Adaptable State
  • The Before Adaptable State Change Event fires immediately before that update
  • The AdapTable State Reloaded Event fires when State reloads

AdapTable provides a stream of every change to AdapTable State.

That covers Redux-backed updates after the Grid is ready — Layouts, searches, styles, Module objects and similar — not mouse clicks, and not AG Grid data edits.

Hint

The Event's messages can easily be streamed to 3rd party monitoring applications for use by Support Teams

Note

There is also an Adaptable State Reloaded Event which fires when the State is reloaded

AdapTable State Changed Event

The Adaptable State Changed Event is fired every time that any Adaptable State changes.

The Event's Info provides very extensive information about the State Change in question including:

  • what action triggered the change
  • who was the user
  • when it happened
  • which AdapTable instance
  • before and after copies of Adaptable State
Adaptable State Changes
Fork
  • In this example we listen to the Adaptable State Changed Event and output each Message:
    • In full to the console
    • As a System Status Message with the Action Name as the Header and the full message as the Description
Try It Out
  • Perform some typical activity in the Grid and open System Status screen to see the full details of all the messages sent
Loading demo…

Filtering State Changed Messages

The Event's Args can be filtered so only particular actions are logged.

Hint

This allows Support Teams to listen only to the grid changes that they are interested in

Filtering Adaptable State Changed Messages
Fork
  • In this example we filter the Adaptable State Changed Event only to log messages relating to Quick Search, Column Filters and the Grid Filter.
  • We send the messages provided by the Event:
    • In full to the console
    • As a System Status Message with the Action Name as the Header and the full message as the Description
Try It Out
  • Run some quick searches and see the Event messages that are sent
  • Perform other Grid actions and note that nothing is sent processed by the Event
Loading demo…

Actions

Each State Change is triggered by a Redux Action (the technical solution Adaptable uses to manage state)

Each Action contains useful objects pertaining to that particular change.

Action Names

To help Support Teams, the actionName property in the Action is also provided as a full level property.

It describes exactly what the Action does, and can be used to listen to a particular State Change.

For instance to react to values being changed in a FreeText Column you would do:

api.eventApi.on(
  'AdaptableStateChanged',
  (statechangedInfo: AdaptableStateChangedInfo) => {
    if (
      statechangedInfo.actionName == 'FREE_TEXT_COLUMN_ADD_EDIT_STORED_VALUE'
    ) {
      // do something with the change
    }
  }
);
Deep Dive

Full Action Name List

Other State Events

AdapTable provides 2 other Events that handle changes in AdapTable State:

Before AdapTable State Change

The BeforeAdaptableStateChange Event fires before a change is made in AdapTable State.

Hint

  • This is very useful if you wish to show a progress indicator for an action which takes several seconds
  • Or if there are other actions which you wish to perform while the State changes

The EventInfo contains the current State and the Redux Action which is about to be performed.

Caution

  • It is not possible to cancel the Redux Action with this Event
  • Do not use this event to mutate the Adaptable state (e.g. to dispatch another action)

AdapTable State Reloaded

The AdaptableStateReloaded Event fires whenever the AdapTable State reloads.

The EventInfo contains the new and old state allowing users easily to diff the changes.