NeuronControllerShorthand extension
Extension providing ultra-short signal factory methods on NeuronController.
This extension uses $ prefix for maximum brevity. Choose this style
if you prefer concise code and your team is familiar with the convention.
Usage
class CounterController extends NeuronController {
late final count = $(0); // Signal<int>
late final name = $(''); // Signal<String>
late final user = $async<User>();
late final doubled = $computed(() => count.val * 2);
}
Comparison
| Verbose | Clean | Short |
|---|---|---|
Signal<int>(0).bind(this) |
signal(0) |
$(0) |
AsyncSignal<T>().bind(this) |
asyncSignal<T>() |
$async<T>() |
Computed(() => x).bind(this) |
computed(() => x) |
$computed(() => x) |
Methods
-
$<
T> (T initial, {String? debugLabel, bool equals(T prev, T next)?, T guard(T current, T next)?, VoidCallback? onListen, VoidCallback? onCancel}) → Signal< T> -
Available on NeuronController, provided by the NeuronControllerShorthand extension
Creates a Signal with ultra-short syntax. -
$async<
T> ({T? initial, String? debugLabel}) → AsyncSignal< T> -
Available on NeuronController, provided by the NeuronControllerShorthand extension
Creates an AsyncSignal with ultra-short syntax. -
$computed<
T> (T computation(), {String? debugLabel}) → Computed< T> -
Available on NeuronController, provided by the NeuronControllerShorthand extension
Creates a Computed signal with ultra-short syntax.