The Fancy streams

With the idea of empowering the streams, this lib was created, making it super ultra easy to use in any project, it makes a perfect pair with the Bloc architecture, but it is modern and independent and can be used in any other context.

Not recommend it for those who are learning to work with streams, because of the ease that this lib provides if you are starting you will not learn the basics of using streams.

Published at:

codecov pub_package pub_package

Let's hands on code:

Traditional Way - Working on events/State

The boring and traditonal way to use streams is almost like that, you need a controller,sink and stream, for each stream that you will work on and you will need close/cancel every necessary object. YourBloc

class HomeBloc  {
  BehaviorSubject<HomeEvent> _controller =  BehaviorSubject();
  Function(HomeEvent) get dispatchEvent => _controller.sink.add;
  Stream<HomeEvent> get homeEvents$ => _controller.stream;
  StreamSubscription subscription;
  
  HomeBloc(){
    subscription = homeEvents$.listen(_handleEvents);
    dispatchEvent(LoadTalks());
  }
  
  dispose(){
    _controller.close();
    subscription?.cancel();

  }
}

yourWidget

 StreamBuilder<HomeEvent>(
                    stream: homeBloc.homeEvents$,
                    builder:...);                 

When you are working on a compelx widget with then or more streams, will be more than 30 lines of boilerplate, and everyone HATES boilerplate.

Fancy Way - Working on events/State

Now i will show you a power of fancy streams, with 0 lines of boilerPlate.

YourBloc

class HomeBloc extends FancyDelegate {

  HomeBloc() {    
    listenOn<HomeEvent>(_handleEvents);
    dispatchOn<HomeEvent>(LoadTalks());
  }
}

the Disposable.dispose function already call cleanAll of power streams.

yourWidget

 StreamBuilder<HomeEvent>(
                    stream:  homeBloc.streamOf<HomeEvent>(),
                    builder:...);                 

Traditional Way - Working on Forms

Fancy Way - Working on forms

Libraries

fancy_stream