ConvertComputed<T, U> constructor

ConvertComputed<T, U>(
  1. Signal<U> source, {
  2. required T decode(
    1. U value
    ),
  3. required U encode(
    1. T value
    ),
  4. T? initialValue,
  5. JoltDebugFn? onDebug,
})

Creates a type-converting computed signal.

Parameters:

  • source: The source signal to convert from
  • decode: Function to convert from source type to target type
  • encode: Function to convert from target type to source type
  • initialValue: Optional initial value for the computed
  • onDebug: Optional debug callback

Implementation

ConvertComputed(this.source,
    {required this.decode,
    required this.encode,
    super.initialValue,
    super.onDebug})
    : super(
        () => decode(source.value),
        (value) => source.value = encode(value),
      );