javascript - Analogues $apply or $digest(Angular) in Aurelia -


is there analogues functions $apply or $digest in aurelia ? how call changes bindingvalue?

my case: have tree(each node contain list of item, screen 1). have parent component(names: tree), , node component(names:node). each node have toggle button. when i'm toggle items parent component should know how changes content height.

togglenode(event) {     (var = 0, length = this.current.children.length; < length;  i++) {         this.current.children[i].visible = !this.current.children[i].visible;     }    //some code     this.evaggregator.publish("toggle-agents", event); } 

view:

<ol show.bind="current.visible">//some markup</ol>          

my parent component catch event , check content size:

@autoinject export class agents {   constructor(private evaggregator: eventaggregator) {     this.toggleagentssubscriber = this.evaggregator.subscribe("toggle-  agents", (e) => {       //some code recalculate content height     });   } 

}

now code execute that: 1) this.current.children[i].visible = false(when node collapse) 2) fire event "toggle-agents" 3) subscriber catch event (recalculate height) 4) in depth @ aurelia observerlocator update (visible property) in dom , height changes.

i need: 1) this.current.children[i].visible = false(when node collapse) 2) in depth @ aurelia observerlocator update (visible property) in dom , height changes. 3) fire custom event. 4) subscriber catch event , recalculate height when height content changes.

in aurelia, changes applied part. aurelia uses dirty checking computed properties (properties getter function). if wanted manually invoke dirty-checking, this:

import {dirtychecker} 'aurelia-binding'; import {inject} 'aurelia-dependency-injection';  @inject(dirtychecker) export class foo {   constructor(dirtychecker) {     dirtychecker.check(); // force application-wide dirty check   } } 

in practice, sort of thing never needed in aurelia app. if have specific bindings want force update can use signal binding behavior:

<template>   <label>${foo & signal:'my signal name'}</label> </template> 
import {bindingsignaler} 'aurelia-templating-resources'; import {inject} 'aurelia-dependency-injection';  @inject(bindingsignaler) export class foo {   constructor(signaler) {     signaler.signal('my signal name'); // evaluate bindings 'my signal name'   } } 

try stay away these 2 techniques if can. if you're using other time-based bindings (binding uses date.now() or new date()) or internationalization locale-changed events... might not doing "aurelia way".


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -