simple_observable 0.1.0 copy "simple_observable: ^0.1.0" to clipboard
simple_observable: ^0.1.0 copied to clipboard

outdated

A minimal observable and debouncer that works with callbacks, Futures, Streams, or any combination of the three.

simple_observable #

A minimal observable and debouncer that works with callbacks, Futures, Streams, or any combination of the three.

Usage #

import 'package:simple_observable/simple_observable.dart';

void main() {
  // Without a callback
  final observable = SimpleObservable<String>();
  // With a callback
  final observable2 = SimpleObservable<String>(print);

  // Using a Future
  observable.nextValue.then((value) => print('Future: $value'));

  // Using a Stream
  observable.values.listen((value) => print('Stream: $value'));

  // Changing its value
  observable.value = 'foo';
  observable.value = 'bar';


  // Debouncing
  final debouncer = Debouncer<String>(Duration(milliseconds: 250));

  // Everything works the same as above.

  // Using a Future
  debouncer.nextValue.then((value) => print('Future: $value'));

  // Using a Stream
  debouncer.values.listen((value) => print('Stream: $value'));

  // Changing its value
  debouncer.value = 'foo';
  debouncer.value = 'bar';
}
4
likes
0
pub points
76%
popularity

Publisher

verified publisherdefylogic.dev

A minimal observable and debouncer that works with callbacks, Futures, Streams, or any combination of the three.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on simple_observable