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
| import { MobxAngularModule } from 'mobx-angular'; | |
| @NgModule({ | |
| declarations: [...COMPONENTS], | |
| imports: [MobxAngularModule ...], | |
| bootstrap: [AppComponent] | |
| }) | |
| export class AppModule { } |
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
| npm install mobx | |
| npm install mobx-angular |
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: 'parent', | |
| template: ` | |
| <span>{{ name }}</span> | |
| <child [text]="text"></child> | |
| ` | |
| }) | |
| export class ParentComponent { | |
| ... | |
| } |
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: 'parent', | |
| template: ` | |
| <span>{{ name }}</span> | |
| <child></child> | |
| ` | |
| }) | |
| export class ParentComponent { | |
| ... | |
| } |
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
| function checkAndUpdateText(view: ViewData, nodeIndex: number, ...): boolean { | |
| if (checkAndUpdateBinding(view, nodeDef, ...)) { | |
| // update DOM here | |
| } | |
| } |
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
| function checkAndUpdate(view: ViewData, nodeIndex: number, ...): boolean { | |
| switch (view.def.nodes[nodeIndex].flags & NodeFlags.Types) { | |
| case NodeFlags.TypeElement: | |
| return checkAndUpdateElement(view, nodeDef, ...); | |
| case NodeFlags.TypeText: | |
| return checkAndUpdateText(view, nodeDef, ...); | |
| case NodeFlags.TypeDirective: | |
| return checkAndUpdateDirective(view, nodeDef, ...); | |
| } | |
| } |
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
| function (checkAndUpdate, viewData) { | |
| var component = viewData.component; | |
| // here node index is 1 and property is `name` | |
| var currentValue_0 = component.name; | |
| checkAndUpdate(viewData, 1, 0, currentValue_0); | |
| // here node index is 4 and bound property is `age` | |
| var currentValue_1 = component.age; | |
| checkAndUpdate(viewData, 4, 0, currentValue_1); | |
| }); |
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
| <h1>Hello {{name}}</h1> | |
| <h1>Hello {{age}}</h1> |
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
| function (checkAndUpdate, viewData) { | |
| var component = viewData.component; | |
| var currentValue = component.name; | |
| checkAndUpdate(viewData, 1, 0, currentValue); | |
| }); |
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 factory | |
| function View_AComponent_0(l) { | |
| return jit_viewDef1( | |
| ... | |
| // update renderer | |
| function (_ck, _v) { | |
| var _co = _v.component; | |
| var currVal_0 = _co.name; | |
| _ck(_v, 1, 0, currVal_0); | |
| } |