Amateras Counter

HTML

<script src="https://unpkg.com/amateras"></script>

JavaScript

import 'amateras';
import 'amateras/signal';
import 'amateras/widget';

const Counter = $.widget(() => ({
    layout() {
        const count$ = $.signal(0);
        const double$ = $.compute(() => count$() * 2);

        console.log('This template only run once.');

        $('h1', $$ => $`Counter`)

        $('button', $$ => { $(double$)
            $$.on('click', () => count$.set(val => val + 1));
        })
    }
}))

$.render($(Counter), () => document.body);