nothin_but_the_bloc 0.0.3 copy "nothin_but_the_bloc: ^0.0.3" to clipboard
nothin_but_the_bloc: ^0.0.3 copied to clipboard

discontinued

A library that aims to make BLoC principles more intuitive to implement.

A library that aims to make BLoC principles more intuitive to implement.

Usage #

A simple usage example:

import 'package:nothin_but_the_bloc/nothin_but_the_bloc.dart';
   
class BlocEmitter extends Bloc {
  Emitter<int> emitter = Emitter();

  void emitValue(int data) {
    print('BlocEmitter is broadcasting an event: $data');
    emitter.emit(data);
  }

  void dispose() {
    emitter.close();
  }
}

class BlocSubscriber extends Bloc {
  Subscriber<int> subscriber;

  BlocSubscriberA(BlocEmitter bloc) {
    subscriber = bloc.emitter.createSubscriber(onEvent: onEvent);
  }

  void onEvent(int data) {
    print('BlocSubscriber received event from BlocEmitter: $data');
  }
}

void main() {
  final blocEmitter = BlocEmitter();
  final blocSubscriber = BlocSubscriber(blocEmitter);
  
  emitter.emitValue(5);
  
  // Printed:
  // BlocEmitter is broadcasting an event: 5
  // BlocSubscriber received event from BlocEmitter: 5
  
  blocSubscriber.dispose();
  blocEmitter.dispose();
}

For a more extended example, see the example project.

TODO #

  • Make more comprehensive documentation
  • Override StreamController and Subject inherited methods in Emitter and Subscriber to return an Emitter/Subscriber (so they can be properly chained)
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A library that aims to make BLoC principles more intuitive to implement.

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

meta, rxdart

More

Packages that depend on nothin_but_the_bloc