ActionExt3<A, B, C, R> extension

Extension on a 3-argument function to wrap it in a type-safe action.

Enables calling .action directly on any 3-argument function to wrap it.

Example Usage

import 'package:preact_signals/preact_signals.dart';

final latitude = signal(0.0);
final longitude = signal(0.0);
final locationName = signal('Unknown');

void setCoordinates(double lat, double lng, String label) {
  latitude.value = lat;
  longitude.value = lng;
  locationName.value = label;
}

// Create a batched, untracked action from the function
final setCoords = setCoordinates.action;

void main() {
  effect(() => print('${locationName.value}: (${latitude.value}, ${longitude.value})'));
  // Prints: "Unknown: (0.0, 0.0)"

  setCoords(37.7749, -122.4194, 'San Francisco');
  // Updates latitude, longitude, and locationName inside a batch.
  // Triggers the effect exactly once.
  // Prints: "San Francisco: (37.7749, -122.4194)"
}
on
  • R Function(A, B, C)

Properties

action → R Function(A, B, C)

Available on R Function(A, B, C), provided by the ActionExt3 extension

Wraps the 3-argument function in a type-safe action.
no setter