Skip to content
Browse files

Eliminated Relation#onLocalUpdate

  • Loading branch information...
1 parent a3b40a3 commit 89d0058bb23920e2eab6e0ea7b6d4535508b4d9b @nathansobo committed
View
2 lib/monarch/model/record.js
@@ -2,7 +2,7 @@
constructorProperties: {
initialize: function() {
this.delegateConstructorMethods('find', 'fetch', 'findOrFetch', 'tuples', 'first', 'each', 'onEach', 'map', 'any',
- 'onLocalUpdate', 'onInsert', 'onUpdate', 'onRemove', 'onDirty', 'onClean', 'onInvalid',
+ 'onInsert', 'onUpdate', 'onRemove', 'onDirty', 'onClean', 'onInvalid',
'onValid', 'where', 'contains', 'orderBy', 'project', 'union', 'difference', 'empty',
'build', 'create', 'createFromRemote', 'fixture', 'clear', 'table');
},
View
5 lib/monarch/model/relations/relation.js
@@ -169,11 +169,6 @@ _.constructor("Monarch.Model.Relations.Relation", {
return this.tuples()[i];
},
- onLocalUpdate: function(callback, context) {
- this.subscribeToOperandsIfNeeded();
- return this.onLocalUpdateNode.subscribe(callback, context);
- },
-
onInsert: function(callback, context) {
this.subscribeToOperandsIfNeeded();
return this.onInsertNode.subscribe(callback, context);
View
5 spec/monarch/http/server_spec.js
@@ -187,7 +187,7 @@ Screw.Unit(function(c) { with(c) {
useLocalFixtures();
describe("#create(newRecord)", function() {
- var record, tableInsertCallback, tableUpdateCallback, tableRemoveCallback,
+ var record, tableInsertCallback, tableRemoveCallback,
recordCreateCallback, recordUpdateCallback;
before(function() {
@@ -321,9 +321,7 @@ Screw.Unit(function(c) { with(c) {
userId: 'wil'
});
- var tableLocalUpdateCallback = mockFunction('tableLocalUpdateCallback');
var recordLocalUpdateCallback = mockFunction('recordLocalUpdateCallback');
- Blog.onLocalUpdate(tableLocalUpdateCallback);
record.onLocalUpdate(recordLocalUpdateCallback);
record.afterLocalUpdate = mockFunction('optional afterLocalUpdate hook');
@@ -365,7 +363,6 @@ Screw.Unit(function(c) { with(c) {
// remote update may change local field values but they should not fire local update callbacks because
// the change was initiated remotely
- expect(tableLocalUpdateCallback).toNot(haveBeenCalled);
expect(recordLocalUpdateCallback).toNot(haveBeenCalled);
expect(record.afterLocalUpdate).toNot(haveBeenCalled);
});
View
12 spec/monarch/model/record_spec.js
@@ -184,10 +184,8 @@ Screw.Unit(function(c) { with(c) {
it("calls setter methods for each key in the given hash and fires update callbacks with all changes", function() {
var record = Blog.fixture('recipes');
- var tableUpdateCallback = mockFunction('tableUpdateCallback');
var recordUpdateCallback = mockFunction('recordUpdateCallback');
- Blog.onLocalUpdate(tableUpdateCallback);
record.onLocalUpdate(recordUpdateCallback);
record.afterLocalUpdate = mockFunction('optional afterLocalUpdate hook');
record.otherMethod = mockFunction('other method');
@@ -227,8 +225,6 @@ Screw.Unit(function(c) { with(c) {
}
};
- expect(tableUpdateCallback).to(haveBeenCalled, once);
- expect(tableUpdateCallback).to(haveBeenCalled, withArgs(record, expectedChangeset));
expect(recordUpdateCallback).to(haveBeenCalled, withArgs(expectedChangeset));
expect(record.afterLocalUpdate).to(haveBeenCalled, withArgs(expectedChangeset));
});
@@ -240,10 +236,8 @@ Screw.Unit(function(c) { with(c) {
record = Blog.fixture('recipes');
});
- they("trigger optional onLocalUpdate hooks on the record and onLocalUpdate callbacks the record and its table when a new value is assigned", function() {
- var tableUpdateCallback = mockFunction('table update callback')
+ they("trigger optional onLocalUpdate hooks and callbacks on the record when a new value is assigned", function() {
var recordUpdateCallback = mockFunction('record update callback')
- Blog.onLocalUpdate(tableUpdateCallback);
record.onLocalUpdate(recordUpdateCallback);
record.afterLocalUpdate = mockFunction("optional afterLocalUpdate hook");
@@ -262,17 +256,13 @@ Screw.Unit(function(c) { with(c) {
}
};
- expect(tableUpdateCallback).to(haveBeenCalled, once);
- expect(tableUpdateCallback).to(haveBeenCalled, withArgs(record, expectedChangeset));
expect(recordUpdateCallback).to(haveBeenCalled, withArgs(expectedChangeset));
expect(record.afterLocalUpdate).to(haveBeenCalled, withArgs(expectedChangeset));
- tableUpdateCallback.clear();
recordUpdateCallback.clear();
record.afterLocalUpdate.clear();
record.name('Pesticides');
- expect(tableUpdateCallback).toNot(haveBeenCalled);
expect(recordUpdateCallback).toNot(haveBeenCalled);
expect(record.afterLocalUpdate).toNot(haveBeenCalled);
});

0 comments on commit 89d0058

Please sign in to comment.
Something went wrong with that request. Please try again.