felangel/sealed_flutter_bloc

BlocListener?

antholeole opened this issue · 1 comments

Is there a way to use this with bloc listener? currently, I'm literally just taking the state and doing:

BlocListener<MyCubit, MyState>(
      listener: (context, state) {
          state.join(
              (_) {}, //empty here, as we don't do anything with this state
              (wantedState) => print(wantedState.wantedProperty); //do something here
         );
    }
)

Is it possible to have a function on on a state like:

state.on<WantedState>((wantedState) => print(wantedState.wantedProperty));

so that you can choose to only react to a single state as opposed to needing to put a voider function on every unwanted state?

This package is discontinued in favor of sealed class modifiers introduced in Dart 3.0.