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

outdated

A predictable state management library with prebuilt concurrency helpers that implement the Business Logic Component design pattern without complexity of BLoC.

streamed_controller #

Tiny predictable state management library with prebuilt concurrency helpers that implement the Business Logic Component design pattern without complexity of BLoC.

Features #

  • Concurrency: supports variative concurrency mixins (droppable, throttled, debounced, concurrent, restartable)
  • Lightweight: tiny solution in 3 files without any external dependencies
  • Ready to complex state managment: can handle many various cases like auth, pagination, notifications, complex loading and state handling

Getting started #

flutter pub add streamed_controller

Usage #

  1. Define controller class (and state class, if you using streamed_controller for complex state managment):
class TestControllerBase extends BaseStreamedController<int> {
TestControllerBase() : super(initialState: 0);

Future<void> incrementAwaitable() => handleStream(() async* {
        yield 1;
        await Future.delayed(const Duration(seconds: 1));
        yield 2;
    }());

void increment() => handleStream(() async* {
        yield 3;
        await Future.delayed(const Duration(seconds: 2));
        yield 4;
    }());
}
  1. Create controller variable in any place where you ready to store it (Stateful Scopes, Singletons or other storages):
final $controller = TestControllerBase();
  1. Wrap widget which will reacts to controller changes into ListenableBuilder/AnimatedBuilder:
ListenableBuilder(
    listenable: $controller,
    builder: (context, child) => Text(
            '${$controller.state}',
            style: Theme.of(context).textTheme.headlineMedium,
        ))
  1. And then call these functions from your code
FloatingActionButton(
    onPressed: $controller.increment,
    tooltip: 'Async increment',
    child: const Icon(Icons.add),
)

2023, Archie Iwakura (hot-moms)

2
likes
0
points
49
downloads

Publisher

unverified uploader

Weekly Downloads

A predictable state management library with prebuilt concurrency helpers that implement the Business Logic Component design pattern without complexity of BLoC.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, meta

More

Packages that depend on streamed_controller