How to add calculated getter in a existing store?

const [store, setStore] = createStore({firstName: "Foo", lastName: "Bar"})
11 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
REEEEE
REEEEE2y ago
const [store, setStore] = createStore({
firstName: "foo",
lastName: "bar",
get fullName(){
return this.firstName + this.lastName
}
})
const [store, setStore] = createStore({
firstName: "foo",
lastName: "bar",
get fullName(){
return this.firstName + this.lastName
}
})
Sorry on mobile
PureSoul
PureSoul2y ago
@._rb I want to set it after store is created. @ofabram This is not working.
REEEEE
REEEEE2y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
Otonashi
Otonashi2y ago
this isn't reactive though you probably can't do this, if the properties you want to set aren't top level you can but you'd have to replace the entire object
REEEEE
REEEEE2y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
Otonashi
Otonashi2y ago
but that's not really a getter
Otonashi
Otonashi2y ago
anyway it turns out the copy produce gives you works with defineProperty so this works https://playground.solidjs.com/anonymous/c7b438d5-42e6-464d-aa01-73dd755423e1
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
Otonashi
Otonashi2y ago
Solid Playground
Quickly discover what the solid compiler will generate from your JSX template
REEEEE
REEEEE2y ago
Oh nice, good to know
PureSoul
PureSoul2y ago
@otonashi9 Thanks
Want results from more Discord servers?
Add your server