Closed sandersdevelopments closed 10 months ago
Looks like the ....entity(entity.Id).destroy() method never returns anything..
Hi @sandersdevelopments
A few months ago I changed the implementation of the batch type request to incorporate the Json type representation and on the other hand remove the conversion to promise that was made on the send of the batch.
The exec forced the execution of the send and returned the execution of the context, in his example the batchDelete function was always executed. In the new implementation, to execute the batch it is necessary to subscribe to its return otherwise it will not be sent to the server.
In this way it is achieved that the execution of the batch and subsequent interpretation of the response remain connected, for your example:
public batchDelete<T extends IEntity>(endpoint: ENDPOINT, entities: T[]) {
return this.client
.batch(endpoint)
.exec(() => {
const linkObservables: Observable<T>[] = [];
entities.map((entity) => {
console.log('Create delete request for entity: ', entity);
linkObservables.push(this.client.entitySet<T>(endpoint).entity(entity.Id).destroy());
});
forkJoin(linkObservables).subscribe(entries => {
console.log('Deletes complete', entries);
});
});
}
this.api.batchDelete<T>(ENDPOINT.T, options.XYZ).subscribe(([resultOfContext, rawResponse]) => {
console.log('Batch completed', resultOfContext, rawResponse);
});
I hope I have helped with the answer, otherwise we can see more in depth the reason for the change.
Hello, it looks like the .exec method is broken somehow since we have updated your npm package. Apparantely you have updated the return type of the exec method (to entries AND the corresponding response) and now it looks like the resulting observable never completes or something? When piping the result of this method (should be an observable) it does not work since the pipe is never triggered:
Can you have a look it this issue is on your side? Thanks!