diff --git a/README.md b/README.md index 6f538c4..774d8c0 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,14 @@ # Async Framework -A lightweight, signal-based framework for building reactive web applications with custom elements and async handlers. +A lightweight, signal-based framework for building reactive web applications +with custom elements and async handlers. [](http://www.youtube.com/watch?v=mShb7a9znUg "Async Framework") ## Core Concepts 1. **Signals**: Reactive state management -2. **Custom Elements**: Web components with async capabilities +2. **Custom Elements**: Web components with async capabilities 3. **Event Handlers**: Async event handling with dynamic imports 4. **JSX Support**: Optional JSX/TSX support for component creation @@ -30,48 +31,51 @@ A lightweight, signal-based framework for building reactive web applications wit ### 1. Signals -Signals are reactive state containers that automatically track dependencies and update subscribers: +Signals are reactive state containers that automatically track dependencies and +update subscribers: + ```tsx - import { signal, computed } from '@async/framework'; +import { computed, signal } from "@async/framework"; - // Create a basic signal - const count = signal(0); +// Create a basic signal +const count = signal(0); - // Read and write to signal - console.log(count.value); // 0 - count.value = 1; +// Read and write to signal +console.log(count.value); // 0 +count.value = 1; - // Create a computed signal - const doubled = computed(() => count.value * 2); +// Create a computed signal +const doubled = computed(() => count.value * 2); ``` ### 2. Custom Elements Create reactive web components using signals: + ```tsx - // counter-element.js - import { signal } from '@async/framework'; +// counter-element.js +import { signal } from "@async/framework"; - export class CounterElement extends HTMLElement { - constructor() { - super(); - this.count = signal(0); - } +export class CounterElement extends HTMLElement { + constructor() { + super(); + this.count = signal(0); + } - connectedCallback() { - this.innerHTML = /*html*/` + connectedCallback() { + this.innerHTML = /*html*/ ` `; - - // Auto-update view when signal changes - const buttonEl = this.querySelector('button'); - this.count.subscribe(newValue => { - buttonEl.textContent = `Count: ${newValue}`; - }); - } - } + + // Auto-update view when signal changes + const buttonEl = this.querySelector("button"); + this.count.subscribe((newValue) => { + buttonEl.textContent = `Count: ${newValue}`; + }); + } +} // in main - customElements.define('counter-element', CounterElement); +customElements.define("counter-element", CounterElement); ``` ### 3. Async Event Handlers @@ -79,75 +83,73 @@ Create reactive web components using signals: Event handlers can be loaded asynchronously and chained: HTML: + ```html - - - - -