Skip to content

Problem when observing multiple objects with same structure #5

@ghost

Description

When observing multiple obects with the same structure the callback is triggerd on non changed objects.

How to reproduce

<!DOCTYPE html>
<head>
  <title>JSON-Patch : Tester</title>
  <script src="lib/angular.js"></script>
  <script src="lib/json-patch-duplex.js"></script>
</head>

<body ng-app ng-controller="controller">
  <input ng-model="model1.FirstName"/>
  <input ng-model="model1.LastName"/>
  <br>
  <input ng-model="model2.FirstName"/>
  <input ng-model="model2.LastName"/>
</body>

<script>

  function controller($scope) {

      $scope.model1 = { FirstName:"Model A", LastName:"Model A"};
      $scope.model2 = { FirstName:"Model B", LastName:"Model B"};

     // Observe the model
      jsonpatch.observe($scope.model1, function (patches) {
          console.log("model1:observe callback:" + JSON.stringify(patches));
      });

      jsonpatch.observe($scope.model2, function (patches) {
          console.log("model2:observe callback:" + JSON.stringify(patches));
      });

  }

</script>

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions