dollar 0.3.0 copy "dollar: ^0.3.0" to clipboard
dollar: ^0.3.0 copied to clipboard

outdated

Use $tateful functions everywhere.

dollar #

Build Status

A DSL to keep state in your functions.

Inspired by React hooks.

Usage #


import 'package:dollar/dollar.dart';

final func = $bind((bool input) {
  final a = $cursor(() => 1).value;
  final b = $if(input, () {
    return $cursor(() => 2);
  }, orElse: ()=> $cursor(()=> 3)).value;
  a.value ++; 
  b.value --;
  // a.value & b.value will be kept across calls
}, (_) {});
func(true);
// a.value == 2, b.value == 1
func(true);
// a.value == 3, b.value == 0
func(false);
// a.value == 4, b.value == 2
func(false);
// a.value == 5, b.value == 1

See tests for more examples.

0
likes
20
pub points
0%
popularity

Publisher

unverified uploader

Use $tateful functions everywhere.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

More

Packages that depend on dollar