locked
How to transform a WinJS class into an observable without have to call _initObservable

    Question

  • I wonder why this design is so backward? The class I define has to be prepared to be observable later on. Why does the base class even have to know that it has been mixed with dynamicObservable?

    WinJS.Class.define("Foo", function() {
      this.property = "test";
    }, {
      bar: function() {
        this.property = "test2";
      }
    });

    Now I would like to bind this class and being notified about changes in the "property", without changes to the "Foo" class. How would that be possible?
    Making this work using the Binding.mixin the class would have to look like this:

    WinJS.Class.define("Foo", function() {
      this._initObservable();
      this.addProperty("property", "test");
    }, {
      bar: function() {
        this.property = "test2";
      }
    });
    WinJS.Class.mix(Foo, WinJS.Binding.mixin, WinJS.Binding.expandProperties(Foo));

    What if I want to make 3rd party class bindable? How would I do that?

    Tuesday, October 2, 2012 2:12 PM