ComponentSignal<C extends Component, T> class
A signal that wraps a component's property for reactive updates.
ComponentSignal provides change detection for ECS components, enabling surgical UI updates when component data changes.
final transform = entity.getComponent<TransformComponent>()!;
final positionX = ComponentSignal<TransformComponent, double>(
transform,
getter: (c) => c.position.x,
setter: (c, v) => c.position.x = v,
);
positionX.value = 100; // Updates component and notifies listeners
Constructors
- ComponentSignal(C _component, {required T getter(C component), required void setter(C component, T value), String? debugLabel})
-
A signal over one property of the given component:
getterreads it (and gives the starting value),setterwrites it when value is set to something different.
Properties
- component → C
-
The component this signal wraps.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether this signal has any listeners.
no setterinherited
- listenerCount → int
-
The number of current listeners.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
The current value of the signal.
getter/setter pairoverride
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object notifies its listeners.
inherited
-
dispatchNotifications(
) → void -
Actually dispatches notifications to listeners.
inherited
-
dispose(
) → void -
Disposes this signal and removes all listeners.
inherited
-
forceSet(
T newValue) → void -
Sets the value without checking for equality.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that the
object notifies.
inherited
-
setSilent(
T newValue) → void -
Silently sets the value without notifying listeners.
inherited
-
sync(
) → void - Syncs the signal with the component's current value.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
T updater(T current)) → void -
Updates the value using a function.
inherited
-
watch(
VoidCallback callback) → VoidCallback -
Watches this signal and returns an unsubscribe function.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited