diff --git a/README.md b/README.md
index 7326db5..4f428f0 100644
--- a/README.md
+++ b/README.md
@@ -1,13 +1,17 @@
-# Web Component Base
-
+Web Component Base
+---
This is a very minimal base class for creating reactive custom elements easily.
When you extend the `WebComponent` class for your component, you only have to define the `template()` and `observedAttributes()`, and changes in any attribute value will automatically cause the UI to render.
The result is a reactive UI on attribute changes.
-Optionally, you can
-1. define a method [`onChanges`](#hooks) that gets triggered when an attribute value changed
+## Table of Contents
+1. [Installation](#installation)
+1. [Usage](#usage)
+1. [Life-Cycle Hooks](#life-cycle-hooks)
+ 1. [`onInit`](#oninit) - the component is connected to the DOM
+ 1. [`onChanges`](#onchanges) - an attribute value changed
## Installation
@@ -64,28 +68,40 @@ The result is a reactive UI that updates on attribute changes:
-### Hooks
+## Life-Cycle Hooks
-Currently, you can define behavior when an attribute value changes by defining a method `onChanges` in your component:
+Define behavior when certain events in the component's life cycle is triggered by providing hook methods
+
+### onInit()
+- gets triggered when the component is connected to the DOM
```js
import WebComponent from "../index.mjs";
-export class HelloWorld extends WebComponent {
- name = "World";
- emotion = "excited";
-
- static get observedAttributes() {
- return ["name", "emotion"];
- }
-
- onChanges({ previousValue, currentValue }) {
- console.log(">>> changed", { previousValue, currentValue });
+class ClickableText extends WebComponent {
+ onInit() {
+ this.onclick = () => console.log(">>> click!");
}
get template() {
- return `
-
Simple text ${this.greeting}
`; + return `Click me!`; } }