Popsiclev2.1.0
GitHub ↗
Popsicle docs · 2.1.0

IntentStore

Use an explicit intent boundary for event-driven workflows.

IntentStore

IntentStore is optional structure for workflows where an explicit intent boundary improves readability.

Intent -> IntentStore -> commit(State) -> UI
                    `-> effect(...)   -> one-shot work
sealed class LoginIntent {
  const LoginIntent();
}

final class SubmitLogin extends LoginIntent {
  const SubmitLogin();
}

class LoginStore extends IntentStore<LoginState, LoginIntent> {
  LoginStore() : super(const LoginState());

  @override
  Future<void> onIntent(LoginIntent intent) async {
    switch (intent) {
      case SubmitLogin():
        // commit(nextState);
        break;
    }
  }
}

Dispatch with:

store.dispatch(const SubmitLogin());

Do not introduce intents for every button by default. Normal Store methods remain the simpler default.