knockout-postbox
knockout-postbox copied to clipboard
When publishing a value with a circular reference, a 'cyclic object value' error is thrown
When publishing a value with a circular reference, a 'cyclic object value' error is thrown. This is because of the serialization that happens to fill topicCache
.
Code to reproduce:
const foo = {
id: "foo",
bar: ko.observable()
}
const bar = {
id: "bar",
foo: ko.observable()
}
ko.postbox.subscribe("foo", function() {
console.log("foo was published");
})
ko.postbox.publish("foo", foo); // console: foo was published
foo.bar(bar);
ko.postbox.publish("foo", foo); // console: foo was published
bar.foo(foo);
ko.postbox.publish("foo", foo); // TypeError: cyclic object value
Is this something that can be solved by the library, or is it something I need to solve in my code?