dollar 0.2.0

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
}, (_) {});
// a.value == 2, b.value == 1
// a.value == 3, b.value == 0
// a.value == 4, b.value == 2
// a.value == 5, b.value == 1

See tests for more examples.

0.0.1 #

  • Core functions: $handle, $effect, $cursor and $if.

0.0.2 #

  • Add TravisCI support.
  • Add multiple extensions.

0.0.3 #

  • Rename $handle to $bind.
  • Make $previous a listener.
  • Add utils to help handling effects.

0.1.0 #

  • Add support to Stream.
  • Add bind support to functions with multiple parameters.
  • Add some extensions & utils.
  • Create new context iff a effect handler is provided.

0.1.1 #

  • Make handler interface composable

0.2.0 #

  • Separate $bind into $bind and $unbind
  • Add several operators.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  dollar: ^0.2.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:dollar/dollar.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Aug 21, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19


Detected platforms: Flutter, web, other

No platform restriction found in primary library package:dollar/dollar.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and dollar.dart. Packages with multiple examples should provide example/

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
Dev dependencies
test ^1.0.0