Knockout Observables & Maps

August 29, 2017 • 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.

Jason Butz's profile picture

Jason Butz is a software engineer and cloud architect with a strong focus on JavaScript, TypeScript, Node, and AWS. Jason has a love for open-soure software and a passion for building scalable, secure, and reliable applications.