CodeCoupler UI DataSource "Repeating"
A DataSource Mixin with special request handling.
This DataSource handle the settings transport.read
, transport.create
, transport.destroy
and
trasport.update
different. If the request fails a callback function will be called and afterwards
the request will be repeated. You can filter the status code in which the callback will be used.
This is usefull to intercept unauthorized requests, provide a login procedure to the user and then continue with the work.
The difference to bind a function to the error
event is that the DataSource will not reject the
request all the time. This means that the calling functions will not stop working. They wait until
the request process all the repetitions.
The callback function must be async
and in case the promise will be rejected the whole request
leads to an error.
To configure this feature you can use new properties added to the transport
configuration:
- repeatProcess: function(object)
Callback to call if an specified status code will be returned. The function must be async
and
therefore return a Promise
. If rejected the current CRUD operation will be canceled. Otherwise
the DataSource will repeat the current operation.
The callback function receive the result object of the Ajax call as argument.
If not set, repeting functionality will be disabled.
- repeatOnStatus: number[]
Array of status codes with which the callback will be used. If null
the callback will always be
used.
Set defaults: