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

outdated

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(EmptyServiceModel());
  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, EmptyServiceModel> {
  @override
  Stream<TestState> call(
      ExStore store, TestState state, EmptyServiceModel sm) async* {
    yield TestState(afterInitial: true);
  }
}

class TestBloc extends ExBloc<TestEvent, TestState, EmptyServiceModel> {
  TestBloc(EmptyServiceModel sm) : super(sm);

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

Publisher

unverified uploader

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

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

bloc

More

Packages that depend on ex_bloc