Asked by:
Building a custom observable type

-
Hello guys.
I'm looking at this quickstart http://msdn.microsoft.com/en-us/library/windows/apps/hh700355.aspx and I'm trying to reuse it in my code. So, I've added the following definitions:
var DadosBase = WinJS.Class.define(
function (nome, morada) {
this.nome = nome;
this.morada = morada;
});
var DadosObs = WinJS.Class.mix(DadosBase,
WinJS.Binding.mixin,
WinJS.Binding.expandProperties(DadosBase));Now, the problem: this won't work at runtime because _backingData isn't initialized. After taking a peek at the code, it seems like I'm supposed to call _initObservable from my constructor (the quickstart doesn't even mentions the method). Now, that being the case, I really see no advantages on creating bindable types instead of creating non-bindable types and passing them to the as method.
Comments?
Luis Abreu
- Changed type Matt SmallMicrosoft employee, Moderator Monday, April 02, 2012 6:14 PM
Monday, April 02, 2012 9:20 AM
General discussion
All replies
-
Hello guys.
This is an old thread, but I see that there are still no comments on this.
Any comments?
Luis Abreu
Monday, June 11, 2012 9:19 AM -
Ok, a couple of minuts more and I've got the code working. I've ended up with this code:
var DadosObs = WinJS.Class.mix(function (nome, morada) {
var interno = new DadosBase(nome, morada);
this._initObservable(interno);
Object.defineProperties(this, WinJS.Binding.expandProperties(interno));
},
WinJS.Binding.mixin
);btw, I've noticed that this will also work:
var DadosObs = WinJS.Class.mix(function (nome, morada) {
var interno = new DadosBase(nome, morada);
this._initObservable(interno);
);
},
WinJS.Binding.mixin,
WinJS.Binding.expandProperties(new DadosBase("", "") )
);Now, I'm not sure if this is the correct way to do this, but it does work...Now, can someone from MS comment on the code shown here http://msdn.microsoft.com/en-us/library/windows/apps/hh700355.aspx:
WinJS.Class.mix(Person, WinJS.Binding.mixin, WinJS.Binding.expandProperties(Person) );
It has nothing to do with the final version I've written. Is it wrong? if it is, why is it still online?
thanks.
Luis Abreu
Monday, June 11, 2012 10:51 AM -
putting this back on top :)
Luis Abreu
Thursday, June 14, 2012 9:36 PM -
Can anyone answer this please?
thanks.
Luis Abreu
Wednesday, June 27, 2012 2:25 PM