Skip to content

Commit

Permalink
Don't try updated non-writeable observable
Browse files Browse the repository at this point in the history
  • Loading branch information
halter73 committed Mar 4, 2013
1 parent f44e464 commit ae5c298
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 2 deletions.
Expand Up @@ -24,7 +24,10 @@
},

koUpdate: function (x, newValue) {
return x(newValue);
// TODO: We shouldn't have to make this check. Look into why we do.
if (window.ko.isWriteableObservable(x)) {
return x(newValue);
}
},

identity: function (x) {
Expand Down Expand Up @@ -240,6 +243,9 @@
modelPeek = merge(modelPeek, diff.value, diffTag);
}

// Ideally I will only update if diff._updated, but I'm reverting this
// change since I don't notify the merge function to rebuild after
// "GetKnockoutState" which doesn't include _updated.
if (builder.update) {
builder.update(model, modelPeek);
} else {
Expand Down Expand Up @@ -287,6 +293,15 @@
ko = window.ko,
savedCreateHubProxy = $.hubConnection.prototype.createHubProxy,
defaultBuilders = [{
name: "koReadOnlyObservable",
diffable: true,
match: function (object) {
return ko.isObservable(object) && !ko.isWriteableObservable(object);
},
peek: utils.koPeek,
create: utils.identity,
update: utils.identity
}, {
name: "koObservableArray",
diffable: true,
match: function (object) {
Expand Down
Expand Up @@ -11,6 +11,15 @@
ko = window.ko,
savedCreateHubProxy = $.hubConnection.prototype.createHubProxy,
defaultBuilders = [{
name: "koReadOnlyObservable",
diffable: true,
match: function (object) {
return ko.isObservable(object) && !ko.isWriteableObservable(object);
},
peek: utils.koPeek,
create: utils.identity,
update: utils.identity
}, {
name: "koObservableArray",
diffable: true,
match: function (object) {
Expand Down
Expand Up @@ -158,6 +158,9 @@
modelPeek = merge(modelPeek, diff.value, diffTag);
}

// Ideally I will only update if diff._updated, but I'm reverting this
// change since I don't notify the merge function to rebuild after
// "GetKnockoutState" which doesn't include _updated.
if (builder.update) {
builder.update(model, modelPeek);
} else {
Expand Down
Expand Up @@ -23,7 +23,10 @@
},

koUpdate: function (x, newValue) {
return x(newValue);
// TODO: We shouldn't have to make this check. Look into why we do.
if (window.ko.isWriteableObservable(x)) {
return x(newValue);
}
},

identity: function (x) {
Expand Down

0 comments on commit ae5c298

Please sign in to comment.