From 4211b48b641066b4411c22547cb8057f353274ae Mon Sep 17 00:00:00 2001 From: Tyler Henkel Date: Mon, 17 Feb 2014 19:51:32 -0500 Subject: [PATCH] feat(obBinder): added unbind method --- lib/binder.js | 4 ++++ test/spec/binder.spec.js | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/binder.js b/lib/binder.js index e7c8319..1019696 100644 --- a/lib/binder.js +++ b/lib/binder.js @@ -31,6 +31,10 @@ angular.module('OmniBinder', []) } }; + Binder.prototype.unbind = function () { + this.observer.close(); + }; + /* Respond to local changes to the model 1. Create a delta object to go through the change pipeline diff --git a/test/spec/binder.spec.js b/test/spec/binder.spec.js index b35384e..284a5df 100644 --- a/test/spec/binder.spec.js +++ b/test/spec/binder.spec.js @@ -62,6 +62,23 @@ describe('obBinder', function () { expect(spy).toHaveBeenCalled(); }); }); + + it('should unbind model', function () { + var spy = spyOn(myBinder, 'onModelChange'); + + runs(function () { + scope.boundmodel = []; + myBinder.bindModel(obBinderTypes.COLLECTION, scope, 'boundmodel'); + myBinder.unbind(); + scope.boundmodel.push({foo: 'bar'}); + }); + + waits(100); + + runs(function () { + expect(spy).not.toHaveBeenCalled(); + }); + }); });