blocx 0.1.2 copy "blocx: ^0.1.2" to clipboard
blocx: ^0.1.2 copied to clipboard

BLoC pattern implementation which help with reducing boilerplate which comes with writing traditional BLoC pattern.

BloCX #

BLoC pattern implementation which simplifies process of writing BLoC and minimizes boilerplate which is needed to be written with traditional BLoC pattern implementation.

Usage #

First we need to define actions and state

Actions

abstract CounterAction{

}

class IncrementCounterAction extends CounterAction{
}

State

class CounterState {
  int counter;

  CounterState() : this.counter = 0;
}

Then we implement BloC as follows

class CounterBloc extends Bloc<CounterAction, CounterState> {
  @override
  CounterState get initialState => CounterState();

  @override
  CounterState updateState(CounterState state, CounterAction action) {
    switch (action.runtimeType) {
      case IncrementCounterAction:
        return state..counter = state.counter + 1;
        break;
    }
    return state;
  }
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

BLoC pattern implementation which help with reducing boilerplate which comes with writing traditional BLoC pattern.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

rxdart

More

Packages that depend on blocx