Create a signal that computes a value based on other signals. (Can also be
used as a method decorator via @fn, with either TC39 or "Legacy"
decorators.)
The type of value the created signal will provide.
The function that will be called to compute the result, if the signals it used in its last invocation have changed since then.
A signal that returns a cached value or recomputes it as necessary, and will be tracked as a dependency for other signals, rules, or effects, when they use it in their calculations.
Create a parameterized reactive function that tracks separate dependencies and caching state for each object it's called on.
The type of object the created function will be used with
The type of result the created function will return
a one-argument reactive function that is shorthand for looking up and returning the value of a cached signal customized for the given argument.
That is, given rf = fn(a => () => a.bar), calling rf(foo) is equivalent
to calling fn(() => foo.bar)(), except that each foo gets its own fn(() => foo.bar) signal cached, so that dependencies can be properly tracked
per instance.
Create a computed signal from a function, method, or function-returning function
fn(() => T)Signal<T>fn``(() => T)Signal<T>fn(ob => () => T)ob => Tfn``(ob => () => T)ob => T@fn method(): TTfn``(...)is shorthand for$``(() => fn(...))[3]. That is, it acts just like any other call tofn, except that it only runs at most once per code location in a given signal function. The result is then cached and returned for every subsequent call from that specific location in the same signal function. ↩︎Both TC39 decorators and "legacy" TypeScript/Babel decorators are supported. ↩︎
$``()is the lazy constant operator. It allows for an expression to only be evaluated once during the life of an enclosing signal, by caching the result on its first invocation. ↩︎