computed_collections 0.1.1 copy "computed_collections: ^0.1.1" to clipboard
computed_collections: ^0.1.1 copied to clipboard

Performant and flexible functional reactive programming for collections

example/example.dart

import 'dart:async';

import 'package:computed/computed.dart';
import 'package:computed_collections/change_event.dart';
import 'package:computed_collections/computedmap.dart';
import 'package:fast_immutable_collections/fast_immutable_collections.dart';

void main() {
  final s = StreamController<ChangeEvent<int, int>>(sync: true);
  final stream = s.stream;

  final m = ComputedMap.fromChangeStream($(() => stream.use))
      .removeWhere((key, value) => key % 2 == 1)
      .updateAll((key, value) => value + 1);

  final sub = Computed.effect(() => print(m.snapshot.use));

  // Prints {}

  s.add(ChangeEventReplace({0: 1, 1: 2, 2: 3}.lock));
  // Prints {0:2, 2:4}

  s.add(
      KeyChanges({0: ChangeRecordValue(0), 2: ChangeRecordDelete<int>()}.lock));
  // Prints {0: 1}

  sub.cancel();
}
0
likes
160
pub points
0%
popularity

Publisher

unverified uploader

Performant and flexible functional reactive programming for collections

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

computed, fast_immutable_collections, meta

More

Packages that depend on computed_collections