Store to manage predictable and functional asynchrony
npm install @atomico/storetsx
import { createContext } from "@atomico/store";
const MyStore = createContext({ counter: 0 });
customElements.define("my-store", MyStore);
`
Definicion del store
`tsx
import { c } from "atomico";
import { MyStore } from "./my-store";
export const MyApp = c(() => {
return (
);
});
`
En el codigo anterior hemos diponibilizado el store para todo hijo del webcomponente.
Consumo del store y reactividad.
`tsx
import { c } from "atomico";
import { useStore } from "@atomico/store";
import { MyStore } from "./my-store";
export const MyForm = c(() => {
const store = useStore(MyStore);
return (
counter: {store.counter}
);
});
``