15 lines
317 B
TypeScript
15 lines
317 B
TypeScript
import { Store } from '@tanstack/store'
|
|
|
|
export const store = new Store({
|
|
firstName: 'Jane',
|
|
lastName: 'Smith',
|
|
})
|
|
|
|
export const fullName = new Store(
|
|
`${store.state.firstName} ${store.state.lastName}`,
|
|
)
|
|
|
|
store.subscribe(() => {
|
|
fullName.setState(() => `${store.state.firstName} ${store.state.lastName}`)
|
|
})
|