statebuilder@0.3.0
riccardoperra
released this
25 Feb 21:14
·
86 commits
to main
since this release
Breaking changes
This new version removes withPlugin
introduced in 0.2.4. Instead, now plugins will infer automatically the type, and uses a generic signatureby default.
const store = defineSignal(() => 1).extend(
withProxyCommands<{increment: boolean}>())
);
store.hold(
store.commands.increment,
(command, { set }) => {
// ✅ Now `set` is Setter<number> instead of (...args: any) => void
set(v => v + 1);
});
Create plugins with store constraints
In order to create plugins that must follow a specific store signature, you can now use the .typed
helper of makePlugin function.
const pluginOnlyForStoreLike = () => makePlugin.typed<Store<{ count: number }>>()(store => {
// ...
});
// ❌ pluginOnlyForStoreLike cannot be used anymore since store does not follow the { count : number } state signature
const store1 = defineStore(0).extend(pluginOnlyForStoreLike())
What's Changed
- feat: refactor types for implicit inference by @riccardoperra in #13
- chore: update versions by @github-actions in #14
Full Changelog: https://github.com/riccardoperra/statebuilder/compare/statebuilder@0.2.4...statebuilder@0.3.0