Skip to main content

sinew_presentation 1.0.0 copy "sinew_presentation: ^1.0.0" to clipboard
sinew_presentation: ^1.0.0 copied to clipboard

StateEffectHandler, EventActionHandler and EffectEmitter, framework-neutral.

sinew_presentation #

pub package License Docs

StateEffectHandler, EventActionHandler and EffectEmitter: the presentation pattern, with no framework.

A page has state (what it renders) and effects (one-time reactions, such as a snackbar or a navigation), and effects are never state, so a rebuild can't repeat them. These base classes hold that pattern in plain Dart. sinew_riverpod adapts them to Riverpod notifiers.

Features #

  • StateEffectHandler<S, F> for a page with one intent: setState, emitEffect, and states and effects streams
  • EventActionHandler<S, E, A, F> for a page with several intents: the page sends events, a pure mapEventToAction decides the work, and onAction does it
  • EffectEmitter<F>: each effect is delivered once, to one listener, and held until there is one

Getting started #

dart pub add sinew_presentation

Usage #

final class Counter extends StateEffectHandler<CounterState, ReachedTen> {
  Counter() : super(const CounterState(0));

  void increment() {
    setState((state) => CounterState(state.count + 1));
    if (state.count == 10) emitEffect(const ReachedTen());
  }
}

final counter = Counter();
counter.effects.listen((effect) => print('the counter reached ten'));
counter.states.listen((state) => print('count: ${state.count}'));

The full program is in example/main.dart.

Sinew is one architecture for Flutter and Kotlin, released as a set of packages at one version.

Documentation #

License #

Apache 2.0, see LICENSE.

0
likes
160
points
208
downloads

Documentation

Documentation
API reference

Publisher

verified publishersrctool.com

Weekly Downloads

StateEffectHandler, EventActionHandler and EffectEmitter, framework-neutral.

Repository (GitHub)
View/report issues
Contributing

Topics

#state-management #architecture #mvvm

License

Apache-2.0 (license)

Dependencies

meta

More

Packages that depend on sinew_presentation