Vheissu / aurelia-for-real-world-web-applications-book-feedback

Post feedback as issues here on Github for the Aurelia book. Be as descriptive and honest as you like.
15 stars 0 forks source link

Binding -> Observation Strategies (Notes) #42

Closed wshayes closed 8 years ago

wshayes commented 8 years ago

1

"While moderate use of expressionObserver should have no detrimental effect on your application, it is     more expensive performance wise than propertyObserver, so keep this in mind when deciding to use this observation strategy. You can still use the propertyObserver for deep observation, but it will require looping your object and doing it manually."

I don't understand how to loop through my object and manually observe it. Can you elucidate?

2

Also the following might be a bit hard to follow:

export class MyClass { 
    theList = [1, 2, 3];
    constructor(bindingEngine) {
        // Because `theList` array is being replaced, the view sees the changes
        this.theList = [1, 2, 3, 4, 5, 6]; 
    }
}

This would probably be less confusing (e.g. doing this in a constructor wouldn't have a visible effect) and no need for the bindingEngine from what I can tell (can't call it a typo as I'm not completely sure :)))

export class MyClass { 
    theList = [1, 2, 3];
    myMethod() {
        // Because `theList` array is being replaced, this triggers an update to the view as well
        this.theList = [1, 2, 3, 4, 5, 6]; 
    }
}

3

Would also be good to suggest adding subscription.dispose() to the deactivate() method unless they are going to dispose more aggressively (or does deactivate automatically dispose now?).

4

Is there a preferred way to manually refresh a binding? I've used the copy into tmpVar, delete origVar and copy from tmpVar to originalVar to trigger an update - it's not elegant.

Vheissu commented 8 years ago

Really great catches and suggestions as always @wshayes

Vheissu commented 8 years ago

All of these aforementioned things will be in the next release. The first part (1) was an explanation error, but I clarified what I meant though.

wshayes commented 8 years ago

Thanks - closing it then.