computables 0.0.1 copy "computables: ^0.0.1" to clipboard
computables: ^0.0.1 copied to clipboard

Computables are composable, streamable values.

Computables #

Computables are composable, streamable values.

Streamable #

import 'package:computables/computables.dart';

Computable(2).stream().listen((value) {
  print(value);
  // 2
});

Computable.fromIterable([1,2,3]).stream().listen((value) {
  print(value);
  // 1
  // 2
  // 3
});

## Readable

```dart
final computable = Computable(2);
print(computable.get()) // 2
computable.add(3);
print(computable.get()) // 3

Composable #

final computation = Computable.compute2(
  Computable.fromStream(
    Stream.value(1),
    initialValue: 0,
  ),
  Computable.fromFuture(
    Future.value(2),
    initialValue: 0,
  ),
  (input1, input2) => input1 + input2,
);

computation.stream().listen((value) {
  print(value);
  // 0
  // 1
  // 3
});

Composable Composable #

final computation = Computable.compute2(
  Computable.fromStream(
    Stream.value(1),
    initialValue: 0,
  ),
  Computable.fromFuture(
    Future.value(2),
    initialValue: 0,
  ),
  (input1, input2) => input1 + input2,
);

Computable.compute2(
  composable,
  Computable(1),
).stream().listen((value) {
  print(value);
  // 1
  // 2
  // 4
});

Forwardable #

final computable = Computable.subscriber(initialValue: 0);
final stream = Stream.fromIterable([1, 2, 3]);
computable.forwardStream(stream);

computable.stream().listen((value) {
  print(value);
  // 0
  // 1
  // 2
  // 3
})

Enjoyable? #

Reach out if there's any functionality you'd like added and happy coding!

1
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Computables are composable, streamable values.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on computables