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

outdated

Write side effects in sync functions.

dollar #

Build Status

Write async side effects in sync functions.

Inspired by hooks in React.

Usage #


import 'package:dollar/dollar.dart';

final func = $handle((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
}, (_) {});
// values of a & b will be kept across different 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

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Write side effects in sync functions.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

collection

More

Packages that depend on dollar