Last active
December 14, 2016 09:08
-
-
Save robwormald/240b90ecf21af655ecf28a22a35f5627 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>hello {{name}}</p> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'hello-component', | |
templateUrl: 'hello-component.html' | |
}) | |
export class HelloComponent { | |
name: string; | |
constructor(){ | |
this.name = 'World'; | |
setTimeout(() => this.name = 'World!!!', 1000); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export class View_HelloComponent0 extends AppView { | |
constructor(viewUtils, parentView, parentIndex, parentElement) { | |
super(View_HelloComponent0, renderType_HelloComponent, ViewType.COMPONENT, viewUtils, parentView, parentIndex, parentElement, ChangeDetectorStatus.CheckAlways); | |
this._expr_2 = UNINITIALIZED; | |
} | |
createInternal(rootSelector) { | |
const parentRenderNode = this.renderer.createViewRoot(this.parentElement); | |
this._el_0 = createRenderElement(this.renderer, parentRenderNode, 'p', EMPTY_INLINE_ARRAY, null); | |
this._text_1 = this.renderer.createText(this._el_0, '', null); | |
this.init(null, (this.renderer.directRenderer ? null : [ | |
this._el_0, | |
this._text_1 | |
]), null); | |
return null; | |
} | |
detectChangesInternal(throwOnChange) { | |
const currVal_2 = inlineInterpolate(1, 'hello ', this.context.name, ''); | |
if (checkBinding(throwOnChange, this._expr_2, currVal_2)) { | |
this.renderer.setText(this._text_1, currVal_2); | |
this._expr_2 = currVal_2; | |
} | |
} | |
} |
@slmyers Thats exactly what is happening here, and why we don't see .name
or a reflective property access (this[prop]
) anywhere in the compiled code. * checkBinding
is just an equality check. The example of this is accessing this._expr_2
.
Is it possible to see an entire compiled app?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've read a few articles/posts about how Angular2 change detection is quick because of monomorphic change detection functions. Is an example of this present here? I think it's the
checkBinding(...)
call but I would like to be sure before (or if) I explain to others.