1

Using the new symbol type in ES6 you can set non-iterable properties on objects. However when using Knockout these symbols are not observed by default.

It is possible to bind a symbol's value, but it is never updated as it isn't added to the observable object.

Has anyone been able to work around this problem and force Knockout to observe symbols?

joan16v
  • 5,055
  • 4
  • 49
  • 49

1 Answers1

2

Looks like the observable plugin for Durandal is implemented similarly to the Knockout-ES5 plugin. When applied to a view model it's only going to create observables wrapped in a getter/setter for properties that are enumerable on the object.

observable.defineProperty doesn't accept enumerable as a param but it does have configuration: true. This means that we can use observable.defineProperty (which will make the property enumerable) but then immediately make the property non-enumerable like so...

Object.defineProperty(this, 'myProp', { enumerable: false });
CrimsonChris
  • 4,651
  • 2
  • 19
  • 30