Skip to content

Instantly share code, notes, and snippets.

View ArtemRomanovsky's full-sized avatar

ArtemRomanovsky

View GitHub Profile
function checkAndUpdateText(view: ViewData, nodeIndex: number, ...): boolean {
if (checkAndUpdateBinding(view, nodeDef, ...)) {
// update DOM here
}
}
@Component({
selector: 'parent',
template: `
<span>{{ name }}</span>
<child></child>
`
})
export class ParentComponent {
...
}
@Component({
selector: 'parent',
template: `
<span>{{ name }}</span>
<child [text]="text"></child>
`
})
export class ParentComponent {
...
}
npm install mobx
npm install mobx-angular
import { MobxAngularModule } from 'mobx-angular';
@NgModule({
declarations: [...COMPONENTS],
imports: [MobxAngularModule ...],
bootstrap: [AppComponent]
})
export class AppModule { }
<div *mobxAutorun="{ dontDetach: true }">
...
</div>
@observable
state: any = {
spendings: [],
spendingTypes: []
};
<div *mobxAutorun="{ dontDetach: true }">
...
</div>
@Component({
selector: 'app-component',
templateUrl: './component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class Component {
constructor(public store: Store) {}
changeFunc() {...}
}
@Injectable()
export class Store {
@observable state: any;
@computed get aggregation() {...}
@action changeFunc(data) {...}
}