/vyke-solid-destructurable

Helper to destructure reactive objects - like props or stores - or signals of them into a separate accessors updated individually.

Primary LanguageTypeScript

@vyke/solid-destructurable

Helper to destructure reactive objects - like props or stores - or signals of them into a separate accessors updated individually.

Installation

npm i @vyke/solid-destructurable

API

destructurable

Returns a destructurable object

import { createStore } from 'solid-js'
import { destructurable } from '@vyke/solid-destructurable'

type StoreState = {
	theme?: 'light' | 'dark'
}

type AppProps = {
	title: string
}

function App(props: AppProps) {
	const { title } = destructurable(props)
	const store = createStore<StoreState>({ theme: 'light' })
	const { theme } = destructurable(store, { theme: 'dark' })

	return (
		<div>
			{title()}
			{theme()}
		</div>
	)
}

Others vyke projects