Should AngularJS web services return a deep copy of the response?

I have a long polled web service. Recent responses are cached. The web service notifies subscribers of new data.

Is it good to return a deep copy of the response, or should share data with all subscribers? Or does it just depend on the use case?

+4
source share
2 answers

At first glance, I think this is similar to the case when you need to look for wider use.

. , ? , , .

, , . , , , - - /, .

, , , , , - .

, , service.SaveSomeInformation(responseInformation).

TL; DR , () .

.

http://martinfowler.com/eaaCatalog/serviceLayer.html

, .

.... - , .

+2

, -, .

, .

, , , , , , , , , .

, / , weither , .

, ,

scope.response = bigDataObject;

- :

scope.data = angular.copy( bigDataObject.some.deeper.property );
scope.data.name = 'somethingElse';

, tou , . , , , .

+1

All Articles