ex_bloc 0.3.0 copy "ex_bloc: ^0.3.0" to clipboard
ex_bloc: ^0.3.0 copied to clipboard

ExBloc provide simple way to organize bloc middleware and dispatch events.

example/example.dart

import 'package:ex_bloc/ex_bloc.dart';

main() async {
  final store = ExStore.instance;
  final bloc = TestBloc();
  print('afterInitial: ${bloc.state.afterInitial}');
  store.dispatch(TestEvent()); // or TestEvent().dispatch();
  await Future.delayed(Duration(seconds: 1));
  print('afterInitial: ${bloc.state.afterInitial}');
  store.getState<TestState>();
}

class TestState {
  final bool afterInitial;

  const TestState({this.afterInitial});
  factory TestState.initial() {
    return const TestState(afterInitial: false);
  }
}

class TestEvent extends ExEvent<TestState, TestBloc> {
  @override
  Stream<TestState> call(
      ExStore store, TestBloc bloc) async* {
    yield TestState(afterInitial: true);
  }
}

class TestBloc extends ExBloc<TestEvent, TestState> {

  @override
  TestState get initialState => TestState.initial();
}
8
likes
40
pub points
0%
popularity

Publisher

unverified uploader

ExBloc provide simple way to organize bloc middleware and dispatch events.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

bloc

More

Packages that depend on ex_bloc