Iladarsda
Iladarsda

Reputation: 10696

Angular.js - keeping data in sync after creating new record

What is the best practive for keeping data in sync (server <=> browser) after creating new record?

e.g. After creating new record (HTTP POST to server) should I:

  1. Also add new item to the $scope.someArray

  2. Fetch the latest data from the server?

Upvotes: 0

Views: 227

Answers (1)

Davin Tryon
Davin Tryon

Reputation: 67296

It really depends on your applications consistency requirements. Or if the POST could have effected other things that you might want to refresh.

For the most part, if you have the data, and all you want is the same set of data, save yourself the server call.

BTW, there is a third option that is usually found in REST interfaces:

3 - Send back the latest in response to the POST.

Upvotes: 1

Related Questions