fancy_stream 4.0.0+14 copy "fancy_stream: ^4.0.0+14" to clipboard
fancy_stream: ^4.0.0+14 copied to clipboard

A sophisticated way to use streams, make it even easier to use.

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 #

7
likes
100
pub points
21%
popularity

Publisher

unverified uploader

A sophisticated way to use streams, make it even easier to use.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

get_it, rxdart

More

Packages that depend on fancy_stream