Skip to content

Feature request: global command observer (a BlocObserver for command_it) #22

Open

Description

@yopyop800

One of the best things about Bloc is BlocObserver. With a single class you get a complete live log of your app: which event came in, which state followed, and which errors happened. For debugging and for production logging it is hard to beat.

command_it has the same building blocks:

  • a command run is the equivalent of a Bloc event (name + parameter),
  • the CommandResult is the equivalent of a Bloc state (running, data, error).

The only missing piece is a single global place where all of this comes together. Today Command.loggingHandler is called once per run, on completion, so the "running" state and the moment a command was started never show up in it.

Imagine one global observer that prints a timeline like this for the whole app:

AcceptTerms  started
AcceptTerms  completed
LoadCards    started, param: 5
LoadCards    error: ...

That would make command_it much easier to debug and monitor, and would be a real argument for people who are choosing between command_it and Bloc. I think it could become one of the package's killer features.

Ideally the observer would report:

  • when a command is started (name and parameter),
  • its result (data or error),
  • optionally when a command is created and disposed.

A first small step could be an opt-in way to also call loggingHandler when an async command starts, without changing the current default behavior.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions