Skip to content

Latest commit

 

History

History
45 lines (33 loc) · 900 Bytes

File metadata and controls

45 lines (33 loc) · 900 Bytes
title Best Practices with View Bindings

You want fast view rendering and responsible view bindings are the first step to getting there.

Always prepare data for view binding and avoid method bindings

Bad:

// view markup
<Label text="{{getMyText}} />
// view binding class
export class ViewBinding extends Observable {
  getMyText() {
    return 'label text'
  }
}

This leads to developers doing logic in methods and can cause unnecessary view binding execution further slowing down your view rendering performance.

Good:

// view markup
<Label text="{{myText}} />
// view binding class
export class ViewBinding extends Observable {
  myText = 'label text'
}

This provides for direct 1-1 data projection to view binding resulting in no further JavaScript event loop cycles to process your view rendering.