state_beacon_core 1.0.0 copy "state_beacon_core: ^1.0.0" to clipboard
state_beacon_core: ^1.0.0 copied to clipboard

A reactive primitive and simple state managerment solution for dart.

example/state_beacon_core_example.dart

// ignore_for_file: avoid_print

import 'package:state_beacon_core/state_beacon_core.dart';

void main() {
  final name = Beacon.writable('Bob');
  final age = Beacon.writable(20);
  final college = Beacon.writable('MIT');

  Beacon.effect(() {
    var msg = '${name.value} is ${age.value} years old';

    if (age.value > 21) {
      msg += ' and can go to ${college.value}';
    }
    print(msg);
  });

  // prints "Alice is 20 years old"
  name.value = 'Alice';

  // prints "Alice is 21 years old"
  age.value = 21;

  // prints "Alice is 21 years old"
  college.value = 'Stanford';

  // prints "Alice is 22 years old and can go to Stanford"
  age.value = 22;

  // prints "Alice is 22 years old and can go to Harvard"
  college.value = 'Harvard';
}
3
likes
160
points
485
downloads

Publisher

verified publishernosy.dev

Weekly Downloads

A reactive primitive and simple state managerment solution for dart.

Repository (GitHub)
View/report issues

Topics

#state-management #signal #reactive #beacon

Documentation

API reference

License

MIT (license)

Dependencies

basic_interfaces

More

Packages that depend on state_beacon_core