Skip to content

breeze-client / ChangeRequestInterceptor

Interface: ChangeRequestInterceptor ​

Defined in: src/config/interface-registry.ts:165

Allows manipulating data in DataServiceAdapter before sending to server

Properties ​

oneTime? ​

optional oneTime?: boolean

Defined in: src/config/interface-registry.ts:167

Whether to intercept only one save. If set, the adapter goes back to its no-op interceptor after creating this one.

Methods ​

done() ​

done(requests): void

Defined in: src/config/interface-registry.ts:206

Last chance to change anything about the 'requests' array after it has been built with requests for all of the entities-to-be-saved.

The 'requests' array is the same as 'saveBundle.entities' in many implementations

This method can do anything to the array including add and remove requests. It's up to you to ensure that server will accept the requests array data as valid.

Returned value is ignored.

Parameters ​

requests ​

Object[]

{Array of Object} The adapter's array of request for this changeset.

Returns ​

void

Example ​

ts
this.done = function (requests) {
       // alter the array of requests representing the entire change-set
       // based on the saveContext and saveBundle
   };

getRequest() ​

getRequest(request, entity, index): any

Defined in: src/config/interface-registry.ts:187

Prepare and return the save data for an entity change-set.

The adapter calls this method for each entity in the change-set, after it has prepared a "change request" for that object.

The method can do anything to the request but it must return a valid, non-null request.

Parameters ​

request ​

any

{Object} The object representing the adapter's request to save this entity.

entity ​

Entity

{Entity} The entity-to-be-save as it is in cache

index ​

number

{Integer} The zero-based index of this entity in the change-set array

Returns ​

any

The potentially revised request.

Example ​

ts
this.getRequest = function (request, entity, index) {
       // alter the request that the adapter prepared for this entity
       // based on the entity, saveContext, and saveBundle
       // e.g., add a custom header or prune the originalValuesMap
       return request;
   };

Released under the MIT License.