# What To Do
# Use current as the main output name
This signals to the user of the class what is the intended output of the class.
class Foo {
#current = $state()
get current() {
return this.#current
}
} # Keep your values private and immutable
You don’t want side effects in your internal state
class Foo {
#reactive = $state()
#notReactive
#readonly = $state()
get readonly() {
return this.#readonly
}
} # What not to do
# Do not use $effect.root
Use createSubscriber instead.
class Foo {
constructor() {
$effect.root(() => {
// do thing
})
}
}