Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateEffect ¶
func CreateEffect(fn func(), deps ...GetterFn)
CreateEffect calls the given `fn` when any of the given `deps` change.
func CreateSignal ¶
CreateSignal returns a "getter" and "setter" functions with the given initial value. This implementation is a translation/interpretation of the JavaScript example code from https://www.solidjs.com/guides/reactivity#how-it-works.
func NewFnSubscriber ¶
func NewFnSubscriber() *fnSubscriber
NewFnSubscriber returns a new `Subscriber` implementation that calls the callback passed to `SetFn`. This is useful to easily wrap a Go anonymous function as a `Subscriber`.
Types ¶
type GetterFn ¶
type GetterFn func(...Subscriber) any
GetterFn represents functions which return the current value of a Signal. Passing `Subscriber` implementations to them will call those `Subscriber`s whenever the value of the Signal changes.
func CreateMemo ¶
Memo creates a new Signal that depends on the given deps. This can be used for combining other Signals or caching costly calculations.
type Logger ¶
Logger abstracts the implementation of loggers,
var Log Logger = &defaultLogger{}
Log defines the logger to use in this library. This is by default a no-op logger to reduce binary size. This may be set to `log.Default()` from the Go stdlib to log out.
type SetterFn ¶
type SetterFn func(any)
SetterFn represents functions which set the current value of a Signal. Calling this triggers any `Subscriber`s for the Signal.
type Subscriber ¶
type Subscriber interface {
// Run executes the callback.
Run()
}
Subscriber abstracts the implementation of callbacks which may subscribe to Signal changes.