Skip to content

CodeCoupler UI DataSource Mixin "Repeating"

Part of the CodeCoupler UI Pro package.

A DataSource Mixin with special request handling.

This DataSource handle the settings, 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 default behaviour is to intercept returned status code 401 and execute the system method login.

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(datasource,result)

If not set, repeting functionality will be disabled. Must be a function 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 default method is to call the system method login.

datasource: DataSource

The current datasource that calls the function.

result: Any

The result object of the Ajax call as argument.

repeatMessage: String

The message that will be used by the default method defined in repeatProcess to call the login method.

repeatOnStatus: number[]

Array of status codes with which the callback will be used. If null the callback will always be used.