JSFiddle - React, Tailwind, and code Playground
JavaScript
var vm = {
datum: ko.observable(),
blocker: ko.computed({
read: function() {
throw new Error("Serialization of this model is prohibited.");
this.valueHasMutated();
},
deferEvaluation: true,
owner: this
})
};
try {
console.log("toJSON", ko.toJSON(vm)); // error, as expected
} catch (err) {
console.log("toJSON failed, as expected");
}
console.log("toJS", ko.toJS(vm)); // serializes everything but the blocker.