Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add Beacon.asFuture #6

Merged
merged 7 commits into from
Dec 8, 2023
Merged

Feat: Add Beacon.asFuture #6

merged 7 commits into from
Dec 8, 2023

Conversation

jinyus
Copy link
Owner

@jinyus jinyus commented Dec 8, 2023

Exposes a [FutureBeacon] as a [Future] that can be awaited inside another [FutureBeacon].

var count = Beacon.writable(0);
var firstName = Beacon.derivedFuture(() async => 'Sally ${count.value}');
  
var lastName = Beacon.derivedFuture(() async => 'Smith ${count.value}');

var fullName = Beacon.derivedFuture(() async {

  // no need for a manual switch expression
  final fname = await Beacon.asFuture(firstName);
  final lname = await Beacon.asFuture(lastName);

  return '$fname $lname';
});

@jinyus jinyus merged commit 3c24948 into main Dec 8, 2023
1 check passed
@jinyus jinyus deleted the dev branch December 14, 2023 23:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant