Batch update, create and delete a REST method

Using the resources of Tastypie and AngularJS $, I would like to perform a set of update, create and delete operations.

I am currently broadcasting an event:

$rootScope.$broadcast('save'); 

This event is captured by each controller responsible for creating, updating, and deleting using the $resource service:

 ResourceService.update({id:$scope.id}, $scope.element).$promise.then(function(element) { $scope.$emit('saved'); }); 

Now this causes some race conditions both on the client side and on the server side.

What would be the easiest way to perform this set of operations as a package in REST mode?

+6
source share
1 answer

I recently played with Angular HTTP Batcher

however, if you need a more general JS asynchronous helper, you can use Async

I think this is basically what you are looking for, the blog post from Angular HTTP Batcher is a good read.

0
source

Source: https://habr.com/ru/post/976009/


All Articles