If the supplied function has a non-zero .length
(i.e., it explicitly takes
arguments), it is assumed to be a Source, and the second argument is
a default value for the created signal to use as default value until the
source produces a value.
The source will be subscribed only while the signal is subscribed as a stream, or observed (directly or indirectly) by a rule. While subscribed, the signal will update itself with the most recent value produced by the source, triggering rules or events as appropriate if the value changes. When the signal is once again unobserved (or if the source ends without an error), its value will revert to the supplied default.
If the source ends with an error, however, then the cached function will throw that error whenever called, until/unless it becomes unobserved again. (And thus reverts to the default value once more.)
Create a cached version of a function. The returned callable is also a Signal.
Note: If the supplied function has a non-zero
.length
(i.e., it explicitly takes arguments), it is assumed to be a Source, and the second calling signature below will apply, even if TypeScript doesn't see it that way!)