jasonbutz.info

Knockout Observables & Maps

Knockout.js

I’ve used Knockout.js quite a bit, I was looking at some code and come across an interesting situation. I saw a JS Map object being put into a KO observable which got me thinking. Does Knockout actually support that? Will subscriptions trigger? I hypothesized that they would not, but I had to test it.

See the Pen KO Observables - Maps by Jason Butz (@jasonbutz) on CodePen.

Turns out Knockout doesn’t detect changes to the Map, just like if you edit an object contained in an observable the change won’t be detected.