Skip to content

Latest commit

 

History

History
43 lines (27 loc) · 1 KB

life-cycle-events.md

File metadata and controls

43 lines (27 loc) · 1 KB

Life cycle events

Directives and components can listen for some changes in application related to them.

import {Component, OnInit, OnDestroy, OnChange, OnUpdate} from 'slicky/core';

@Component({
	selector: '[app]',
})
export class App implements OnInit, OnDestroy, OnChange, OnUpdate
{

	public onInit(): void {}
	
	public onDestroy(): void {}
	
	public onChange(inputName: string, changed): void {}
	
	public onUpdate(inputName: string, value: any): void {}

}

OnInit

Called when directive with all of it's bindings (inputs, events and elements) are ready and connected.

OnDestroy

Called when directive is detached from DOM.

OnChange

Called when change in some view property occur. This event is called before directive's input is updated and even before the input's expression is parsed. It can also disable those steps by returning false.

OnUpdate

Called when directive's input's expression is parsed and the input is updated.