Created
September 25, 2025 04:45
-
-
Save dickermoshe/a5f887d57918a9c2fdef3a5f8002a055 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import 'package:signals/signals.dart'; | |
| void main() async { | |
| final number = signal(2); | |
| final squared = computedAsync(() async { | |
| print("Squaring ${number.value}..."); | |
| await Future.delayed(Duration(seconds: 1)); | |
| final result = number.value * number.value; | |
| print("Squared ${number.value} to $result"); | |
| return result; | |
| }, dependencies: [number]); | |
| final cubed = computedAsync(() async { | |
| final m = await squared.future; | |
| print("Cubing ${m}..."); | |
| await Future.delayed(Duration(seconds: 1)); | |
| final result = m * m * m; | |
| print("Cubed ${m} to $result"); | |
| return result; | |
| }, dependencies: [squared]); | |
| effect(() { | |
| print("Current State: " + (cubed.value.value?.toString() ?? "null")); | |
| }); | |
| while (true) { | |
| await Future.delayed(Duration(seconds: 50)); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment