Observable Alerts
Summary
- Observable Alerts fire when an observed event happens to grid data
- There are 3 types of changes which can be observed;
- Row Changes
- Grid Changes
- No Changes
- Observable Alerts leverage AdapTable Rx which can be set to watch for particular changes or behaviour in AG Grid
Alerts can be fired using Observable Expressions which watch for changes (or lack of changes).
These are advanced, reactive-type Expressions, which are triggered by Adaptable Rx.
There are 5 main elements to an Observable Expression:
- Scope - either a particular Row (or set of Rows) or the entire Grid
- Observable Type - can be
ROW_CHANGE,GRID_CHANGE,ROW_ADDEDorROW_REMOVED - Change Type - can be -
MIN,MAX,COUNTorNONE - Duration - how long should the change be observed
- WHERE Clause - limits the change only to rows that match the expression
Find Out More
The AdapTableQL Guide provides full details on writing Observable Expressions
For instance we can set an Alert to fire in each of these use cases:
- a particular row has not changed in the last hour
- a given row has changed 5 times in 10 minutes
- a column / cell value is the highest that its been all day
- there have been no changes in the Grid for 2 hours
- a new row has been added to the Grid
- 3 rows have been removed from the Grid in the last 4 hours
Caution
Observable Expressions require the Alert to have a Scope of All (i.e. the whole row)
Row Changes
The most common use case for Observable Alerts is to see if a particular change has happened in each row.
A row change Observable Alert will watch each (relevant) row in the Grid and fire if needed.
- This demo showcases 2 Alerts which are triggered by Observable Row Change Expressions:
- If Github Stars in any Row changes
3 timeswithin a2 minutetimeframe - When Open Issues count in a Row is the highest value it has been within the last hour - for rows where the
languageisJavaScript
- If Github Stars in any Row changes
- Click the Add Star Action Column button next to
Github Stars; once it is clicked 3 times in a row, the Info Alert will be triggered - Click the Open an Issue Action Column button next to
Open IssuesColumn - if the row matches theWHEREclause, it will trigger the Success Alert
Grid Changes
Another common use case for Observable Alerts is for any change in the Grid.
This is useful if you want to be alerted about all behaviour in the Grid rather than particular rows.
- This example contains 2 Alerts which are triggered by Observable Grid Change Expressions:
- If
LanguageColumn in the Grid changes 3 times within a 5 minute timeframe - If
Github StarsColumn in the Grid changes 2 times within a 1 minute timeframe - but only for rows whereLicenseis 'MIT License'
- If
No Changes
Another use case for Observable Alerts is to watch for no changes in the data.
Hint
This is particularly useful if you have ticking data or you expect some changes at some point
AdapTable can observe for No Change on either a per-Row or a per-Grid basis.
- This demo contains an Alert which is triggered by Observable Expressions watching for No Changes
- The Alert triggers if the Github Stars Column in the Grid is not updated within a
5 secondtimeframe - We have subscribed to the Alert Fired Event and we set Column Formatting for the Github Stars Column
Click the "Turn Off Ticking Data" button and wait for 5 seconds and note the Alert will fire
Row Added / Removed
Observable Alerts can also be used to monitor when Rows have been added or removed from the Grid.
This is done using the ROW_ADDED and ROW_REMOVED Observable Expression keywords.
Find Out More
See Row Change Alerts for more details and accompanying demos
Suspending Alerts
When an Observable Alert is suspended, the subscription is removed, and will be re-created when unsuspended.
Caution
- This means that any changes in the data during the Alert's suspension are not observed
- The count / watch starts again from scratch when the Alert is unuspended