Subscribe to complex object knockoutjs

Sami C.
1 min readNov 19, 2019

--

Today I want to share a handy snippet that let’s you listen on all the properties of a complex object:

ko.computed(function () {    return ko.toJSON(complexObject);}).subscribe(function (result) {
// called whenever any of the properties of complexObject changes
console.log(result);});

Hopefully this helps some people out when debugging!

Happy Coding!

--

--

Sami C.
Sami C.

Written by Sami C.

Freelance Software Engineer

No responses yet