var sharedCount = zx.signal(i32, 0);

pub fn Counter(ctx: *zx.ComponentCtx(struct { initial: i32 })) ?zx.Component {
    const count = ctx.signal(i32, ctx.props.initial);

    return (
        <div @allocator={ctx.allocator}>
            <h5>Component: {count.signal}</h5>
            <h5>Shared: {&sharedCount}</h5>
            <h5>Server: {ctx.props.initial}</h5>
            <button onclick={count.bind(decrement)}>Decrement</button>
            <button onclick={count.bind(increment)}>Increment</button>
            <button onclick={count.bind(zero)}>Zero</button>
            <button onclick={count.reset()}>Reset</button>
            <br /><br />
        </div>
    );
}

fn zero(_: i32) i32 {
    return 0;
}
fn increment(x: i32) i32 {
    sharedCount.set(sharedCount.get() + 1);
    return x + 1;
}
fn decrement(x: i32) i32 {
    return x - 1;
}

const zx = @import("zx");
const std = @import("std");
