lucialand / luciex

Simpler state management
MIT License
20 stars 0 forks source link

Lucia Bindings #2

Open shadowtime2000 opened 3 years ago

shadowtime2000 commented 3 years ago

It would be great to have simple bindings to connect this to Lucia. It would probably be really simple, just a wrapper around this:

atom.subscribe((newVal) => Lucia.use("app", newVal));
shadowtime2000 commented 3 years ago

I think it would be best to hold off on this until aidenybai/lucia#7 is finished to make sure we don't have to create any breaking changes once components are implemented.

shadowtime2000 commented 3 years ago

Maybe instead have the bind function convert an atom into an object that can be more easily read by Lucia for reactivity.

<div l-use="clickerGame">
    <p l-text="`$${store.val}`"></p>
    <button l-on:click="store.dispatch(store.val + 1)">Click!</button>
</div>
import { Atom } from "luciex";
import { bind } from "luciex-lucia";

const ClickStore = new Atom<number>(0);

Lucia.use("clickerGame", {
    store: bind(ClickStore)
});