Skip to content

Commit 792d30d

Browse files
committed
Add isInitialized property to Signal base class
1 parent 7960a10 commit 792d30d

3 files changed

Lines changed: 14 additions & 5 deletions

File tree

packages/solidart/lib/src/solidart.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,11 @@ class Signal<T> extends preset.SignalNode<Option<T>>
620620
_notifySignalCreation(this);
621621
}
622622

623+
/// Whether the signal has been initialized.
624+
///
625+
/// Regular signals are always initialized at construction time.
626+
bool get isInitialized => true;
627+
623628
/// {@macro solidart.signal}
624629
///
625630
/// This is a lazy signal: it has no value at construction time.
@@ -744,9 +749,7 @@ class LazySignal<T> extends Signal<T> {
744749
trackInDevTools: trackInDevTools,
745750
);
746751

747-
/// Whether the signal has been initialized.
748-
///
749-
/// This becomes `true` after the first assignment.
752+
@override
750753
bool get isInitialized => currentValue is Some<T>;
751754

752755
@override

packages/solidart_hooks/CHANGELOG.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## 3.1.3
1+
## 3.2.0-dev.0 (Unreleased)
22

33
- **CHORE**: Bump `flutter_solidart` dependency to `3.0.0-dev.2`.
44

@@ -23,14 +23,18 @@
2323
## 3.0.0
2424

2525
- **BREAKING CHANGE**: `SignalHook` no longer calls `setState` to trigger a rebuild when the signal changes. Instead, you should use `SignalBuilder` to listen to signal changes and rebuild the UI accordingly. This change improves performance and reduces unnecessary rebuilds. You can also use `useListenable` if you want to trigger a rebuild on signal changes.
26+
2627
### Migration Guide
2728

2829
**Before (v2.x):**
30+
2931
```dart
3032
final count = useSignal(0);
3133
return Text('Count: ${count.value}'); // Auto-rebuilds
3234
```
35+
3336
**After (v3.x):**
37+
3438
```dart
3539
final count = useSignal(0);
3640
return SignalBuilder(
@@ -39,11 +43,13 @@
3943
```
4044

4145
Or use `useListenable` for full widget rebuild:
46+
4247
```dart
4348
final count = useSignal(0);
4449
useListenable(count);
4550
return Text('Count: ${count.value}');
4651
```
52+
4753
This is inline with the behaviour of `useValueNotifier` from `flutter_hooks`.
4854

4955
## 2.0.0

packages/solidart_hooks/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: solidart_hooks
22
description: Flutter Hooks bindings for Solidart, suitable for ephemeral state and for writing less boilerplate.
3-
version: 3.1.3
3+
version: 3.2.0-dev.0
44
repository: https://github.com/nank1ro/solidart
55
documentation: https://solidart.mariuti.com
66
topics:

0 commit comments

Comments
 (0)