### @component ##### Basic usage: ```js import { component } from 'app-decorators'; @component() class Item { interval = null; // default properties prefix = 'Hello'; suffix = 'World!'; $ = ::document.querySelector; created() { this.innerHTML = `
${this.prefix} ${this.suffix}
`; } blink(ms = 300){ // return on recalling blink if(this.timeout){ return; } // 'blink' class is toggled into 'p' tag between the interval of 500 ms this.interval = setInterval(() => { this.$('p').classList.toggle('blink'); }, ms); } stop(){ clearTimeout(this.interval); } } ``` now put this this in your html page e.g. body ```htmlHello World
Hello World
Whats up!
**/
```
##### Lifecycle of Component (Custom Elements):
```js
import { component } from 'app-decorators';
class Bean {
origin = 'africa';
}
@component({
extends: 'img'
})
// and its possible to extends from other class
class Coffee extends Bean {
/**
* You can add your custom properties and methods. But be careful when choosing the name
* of property/method because "this" has a direct reference to dom instance
*/
foo = 'Hello';
bar = 'World';
someDoSomethingMethod(){
this.classList.add(this.origin); // see in "class Bean" whats origin is
}
/**
* CustomElements Callbacks
*/
// will called if element is created
created(){
}
// will called if element is in document
attached(){
}
// will called if any attribute changed or added to element
attributeChanged(oldValue, newValue){
}
// will called if element is detached/removed from document
detached(){
}
}
```