Class: AutoRefresh

bcdui.core.lifecycle. AutoRefresh

Support for auto-refreshing a {bcdui.core.DataProvider} in the background and detecting, if new data is available.
After trying to reload every periodSec, args.modifiedIf to see, if new data was sent.
* If the server sent an 'expires' header in the future, our re-load attempts will not even go to the server but be fullfilled from the cache.
* If the server sent a 304, we keep using the latest data sent from server.
Both is supported for example by DataRefreshedFilter for example. Once new data was received from the server, args.onModified will be executed.

new bcdui.core.lifecycle.AutoRefresh(args)

core/lifecycle/autoRefresh.js, line 29
Name Type Description
args Object The parameter map contains the following properties:
Name Type Default Description
model bcdui.core.DataProvider Model to monitor for updates by calling execute(true) and checking with modifiedIf
periodSec number 300 optional Period in sec how often to query the server
activeIf boolean | function true optional Boolean or function to determine whether we should check for model updates, queries all periodSec. Also see strategies below
modifiedIf boolean | function strategy.modifiedIf.wrsTs optional Function called (with the current AutoRefresh as param) to check whether model was updated. Also see strategies below
onModified function strategy.onModified.applyAction optional Function called (with the current AutoRefresh as param) when new model data is available. Also see strategies below
Example
let arModel = myCube.getPrimaryModel().getPrimaryModel();
new bcdui.core.lifecycle.AutoRefresh({ model: arModel });

Members

staticbcdui.core.lifecycle.AutoRefresh.strategy

x Pre-defined strategies for activeIf and onModified arguments of AutoRefresh
Properties:
Name Type Description
activeIf Object Predefined callbacks for args.activeIf
Properties
Name Type Description
bcdIsAutoRefreshInFilter function True if bRef 'bcdIsAutoRefresh' is part of f:Filter of the requestModel of an args.model being a SimpleModel
modifiedIf Object Predefined callbacks for args.modifiedIf
Properties
Name Type Description
wrsTs function Check on /*/@ts
onModified Object Predefined callbacks for args.onModified
Properties
Name Type Description
applyAction function Reload page if modification is found
Example
new bcdui.core.lifecycle.AutoRefresh({
  model: arModel,
  activeIf: bcdui.core.lifecycle.AutoRefresh.strategies.activeIf.bcdIsAutoRefreshInFilter
});

Methods

isActive()

core/lifecycle/autoRefresh.js, line 76
Check whether we are still active according to args.activeIf