toSyncSignal method
Convert a Stream to a synchronous ReadonlySignal and provide an initial value.
This is different from toStreamSignal() because it directly feeds the stream's values
into a standard Signal<T>, allowing you to read the bare, synchronous values directly
instead of wrapping them in an AsyncState.
import 'package:signals_core/signals_core.dart';
final stream = Stream.value(42);
final syncSignal = stream.toSyncSignal(0);
print(syncSignal.value); // 0 (initially)
// After the stream emits:
// print(syncSignal.value); // 42
Implementation
ReadonlySignal<T> toSyncSignal(T initialData) {
final s = signal<T>(initialData);
final connector = connect<T, T>(s);
connector << this;
s.onDispose(connector.dispose);
return s;
}