@tempots/dom
Version:
Fully-typed frontend framework alternative to React and Angular
19 lines (18 loc) • 952 B
TypeScript
import { Renderable, TNode } from '../types/domain';
import { Value } from '../std/value';
/**
* Maps the values emitted by a signal to a renderable function and returns a new renderable function.
*
* While it is tempting to use MapSignal for its simplicity, it is important to remember that the
* renderable function returned by MapSignal will be re-rendered every time the signal emits a new value.
*
* In other contexts link `Ensure` or `OneOf`, the renderable function is only re-rendered when the signal
* changes to a state that requires a different renderable function.
*
* @typeParam T - The type of values emitted by the signal.
* @param vlaue - The signal or value to map.
* @param fn - The function to map the signal values to a renderable/TNode.
* @returns - A new renderable function that represents the mapped signal.
* @public
*/
export declare const MapSignal: <T>(value: Value<T>, fn: (value: T) => TNode) => Renderable;