bloc_helpers 0.0.5+1

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 80

Dart Bloc Pattern helper

What is Bloc pattern ?

bloc_helpers

This package contain helper class and common Bloc Pattern

  • Bloc (base to implement Bloc pattern)
  • RequestBloc
  • CachedRequestBloc
  • SelectorBloc

Bloc class

The bloc class is a simple class that provide dispose function and a disposed boolean

abstract class Bloc {
  bool _disposed = false;

  bool get disposed => _disposed;

  @mustCallSuper
  void dispose() {
    _disposed = true;
  }
}

Request bloc

RequestBloc help to implement async call, it provides following stream ans sink.

Sink<Request> requestSink

Stream<bool> onLoading

Stream<Request> onRequest

Stream<Response> onResponse

CachedRequestBloc add the ability to cache response, to avoid multiple call when request does not change, it provides following stream and sink.

Stream<Response> cachedResponse

Sink<Response> invalidateCacheSink

Sink<Response> updateCachedResponseSink

Usage

import 'package:bloc_helpers/bloc_helpers.dart';
import 'package:meta/meta.dart';

class MyRequestBloc extends RequestBloc<MyRequest, MyResponse> {
  @override
  @protected
  Future<MyResponse> request(MyRequest input) async {
    // TODO: implement request
    return MyResponse();
  }
}

bloc.requestSink.add(MyRequest());

See example

Selector bloc

Selector bloc help implementing a simple selection behavior

final selector = SelectorBloc<String>();

  selector.selected.listen((selected) => print(selected));

  selector.selectSink.add('foo');
  selector.unselectSink.add('foo');

  selector.selectAllSink.add(['foo', 'bar']);

Contributions

This repository is open to Pull Request and new idea :)

0.0.5

  • cleanup abd better README

0.0.4

  • protected request method

0.0.3

  • fix cached response sink

0.0.2

  • add onRequest stream

0.0.1

  • first version

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  bloc_helpers: ^0.0.5+1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:bloc_helpers/bloc_helpers.dart';
  
Version Uploaded Documentation Archive
0.0.5+1 Oct 8, 2018 Go to the documentation of bloc_helpers 0.0.5+1 Download bloc_helpers 0.0.5+1 archive
0.0.5 Sep 18, 2018 Go to the documentation of bloc_helpers 0.0.5 Download bloc_helpers 0.0.5 archive
0.0.4 Sep 3, 2018 Go to the documentation of bloc_helpers 0.0.4 Download bloc_helpers 0.0.4 archive
0.0.3 Aug 28, 2018 Go to the documentation of bloc_helpers 0.0.3 Download bloc_helpers 0.0.3 archive
0.0.2 Aug 27, 2018 Go to the documentation of bloc_helpers 0.0.2 Download bloc_helpers 0.0.2 archive
0.0.1 Aug 7, 2018 Go to the documentation of bloc_helpers 0.0.1 Download bloc_helpers 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
63
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
80
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:bloc_helpers/bloc_helpers.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While there is nothing inherently wrong with versions of 0.0.*, it usually means that the author is still experimenting with the general direction of the API.

Maintain an example.

None of the files in your example/ directory matches a known example patterns. Common file name patterns include: main.dart, example.dart or you could also use bloc_helpers.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=1.23.0 <3.0.0
meta ^1.1.0 1.1.6
rxdart >=0.17.0 <1.0.0 0.18.1