bloc_event 1.0.1 copy "bloc_event: ^1.0.1" to clipboard
bloc_event: ^1.0.1 copied to clipboard

discontinued
outdated

Make the Bloc Events easier to structure

bloc_event #

Make the Bloc Events easier to structure

Getting Started #

Basic Usage #

Create your events base class like followed:

abstract class MyEvent<E> extends Event<MyBloc, MyState, E> {}

Your actual Event should look like:

class DoSomethingEvent extends MyEvent<DoSomethingEvent> {
  final String myData;
  
  DoSomethingEvent(this.myData);
  
  @Override
  Stream<MyState> onTriggered(MyBloc bloc, MyState currentState, DoSomethingEvent event) async* {
    // Do your event stuff here
    yield currentState.copyWith();
  }
}

By extending EventBloc in your Bloc you don't have to implement mapEventToState:

class MyBloc extends EventBloc<MyEvent, MyState> {
  
  @Override
  MyState get initialState => MyState();
  
}

Thats it!!

Testing #

You are now able to test your events seperated easily without even using the bloc

example cooming soon

3
likes
0
pub points
0%
popularity

Publisher

verified publisherownii.com

Make the Bloc Events easier to structure

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

bloc

More

Packages that depend on bloc_event