Observable Expressions
Summary
- Observable Expressions watch for changes (or lack of changes) in data that match a particular pattern
- They do this by utilising advanced reactive techniques (RX)
- When the expression evaluates to
TRUE, AdapTable can perform a specified action. - The Alerts Module supports Observable Expressions
- Queries that contain an Observable Expression can and optionally a include a BooleanExpression
Observable Expressions watch for data changes that match a particular pattern.
Hint
They can also be used to watch for a lack of changes
This is accomplished by leveraging advanced Reactive (Rx) techniques.
Note
Observable Expressions are currently only used in Observable Alerts
Observable Expressions may contain any of Boolean Functions, Scalar Functions or Observable Functions.
Observable Functions
There are 4 main Observable Functions available in an Observable Expression:
ROW_CHANGE
This observes changes in each row in isolation - essentially there is one observer per row.
Note
If using WHERE then only those rows which match the clause will be observed
This allows users to create Alerts saying "tell me if any Row performs a particular change 3 times".
GRID_CHANGE
This observes changes in the entire grid.
This allows users to create Alerts saying 'tell me if nothing in the Grid changes for 5 minutes".
Note
If using WHERE then only the subset of rows which match the clause will be observed
ROW_ADDED
This observes when new Rows have been added to the Grid.
It can take no arguments (any Row is added) or a Count and / or a Timeframe.
ROW_REMOVED
This observes when new Rows have been added to the Grid.
It can take no arguments (any Row is removed) or a Count and / or a Timeframe.
Observable Function Parameters
Each Observable Function has 2 mandatory parameters:
TIMEFRAME
The timeframe is the period of time in which the Observable operates.
This may be defined as a number of:
- seconds (e.g.
30s) - minutes (e.g.
15m) - hours (e.g.
8h)
CHANGE_TYPE
This defines the type of change that is being observed by AdapTable.
Note
CHANGE_TYPE always takes a single parameter which is of type Adaptable Column
Caution
Change Type is not used for ROW_ADDED and ROW_REMOVED observables
There are 4 different Change Types available:
-
MIN- its the smallest change of note in the specified column -
MAX- its the largest change of note in the specified column -
NONE- no changes have occurred in the specified column -
COUNT- a given amount of changes have occurred in the specified columnNote
COUNTrequires an additional numeric param, specifying how many changes are required to fulfill the Expression
Examples
Tell Me When...
// The ItemCount value in a Row changes 3 times within a 5 minute timeframe
ROW_CHANGE( COUNT( [ItemCount], 3) , TIMEFRAME('5m') ) // An Order Cost cell contains its highest value within the last hour
ROW_CHANGE( MAX( [OrderCost] ), TIMEFRAME('1h') ) // The Price column has not ticked - in any row in the Grid - for the last 30 seconds
GRID_CHANGE( NONE( [Price] ), TIMEFRAME('30s') )
// A Row has been added to the Grid
ROW_ADDED()
// 3 Rows have been removed from the Grid in the last 5 minutes
ROW_REMOVED(3, TIMEFRAME('5m') )
WHERE Clause
Optionally, a WHERE clause may be appended to the Observable Expression.
This is a Standard Expression which narrows down the scope of the 'main' part of the Expression.
// The ItemCount value in a Row changes 3 times within a 5 minute timeframe for Active Trades
ROW_CHANGE( COUNT([ItemCount], 3), TIMEFRAME('5m')) WHERE [Status] = 'Active' // No change has occurred in last 15 minutes in the Price column for rows where currency is dollar
GRID_CHANGE( NONE([Price]), TIMEFRAME('15m')) WHERE [Currency] = 'USD'Configuring TimeFrame Size
maxTimeframeSize
Default: 28800000 (~8 hours)Number