All Projects → aloisdeniel → built_bloc

aloisdeniel / built_bloc

Licence: MIT License
Generate the BLoC pattern boilerplate.

Programming Languages

dart
5743 projects
java
68154 projects - #9 most used programming language
objective c
16641 projects - #2 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to built bloc

React-BLoC-pattern
React BLoC pattern
Stars: ✭ 18 (-64.71%)
Mutual labels:  pattern, bloc
IntuneDriveMapping
Generate PowerShell scripts to map network drives on Intune managed Windows 10 devices
Stars: ✭ 51 (+0%)
Mutual labels:  generator
avro-schema-generator
Library for generating avro schema files (.avsc) based on DB tables structure
Stars: ✭ 38 (-25.49%)
Mutual labels:  generator
DataAnalyzer.app
✨🚀 DataAnalyzer.app - Convert JSON/CSV to Typed Data Interfaces - Automatically!
Stars: ✭ 23 (-54.9%)
Mutual labels:  generator
dalal-street-client
Frontend client for Dalal Street
Stars: ✭ 13 (-74.51%)
Mutual labels:  bloc
allot
Parse placeholder and wildcard text commands
Stars: ✭ 51 (+0%)
Mutual labels:  pattern
Competitive-Feature-Learning
Online feature-extraction and classification algorithm that learns representations of input patterns.
Stars: ✭ 32 (-37.25%)
Mutual labels:  pattern
docgen
The docs.json generator for discord.js and its related projects
Stars: ✭ 59 (+15.69%)
Mutual labels:  generator
humans-generator
Humans.txt generator for Node.js
Stars: ✭ 20 (-60.78%)
Mutual labels:  generator
bloc-pattern-example
Detailed example of the BLoC pattern in Flutter
Stars: ✭ 23 (-54.9%)
Mutual labels:  bloc
FrontEnd-Note
FrontEnd Knowledge Package 📦
Stars: ✭ 14 (-72.55%)
Mutual labels:  pattern
nest-angular
Full-stack with nest js & angular 8
Stars: ✭ 32 (-37.25%)
Mutual labels:  generator
NFT Art Generator
No description or website provided.
Stars: ✭ 58 (+13.73%)
Mutual labels:  generator
flutter-clean-arch
A flutter's implementation of a "clean architecture"
Stars: ✭ 149 (+192.16%)
Mutual labels:  bloc
ffmpeg-commander
🛠️ FFmpeg Command Generator Web UI
Stars: ✭ 136 (+166.67%)
Mutual labels:  generator
nomnoml-cli
Generates images from nomnoml diagram sources in a NodeJS module or on the command line
Stars: ✭ 20 (-60.78%)
Mutual labels:  generator
FigmaConvertXib
FigmaConvertXib is a tool for exporting design elements from figma.com and generating files to a projects iOS .xib / Android .xml
Stars: ✭ 111 (+117.65%)
Mutual labels:  generator
prisma-tgql-types-gen
◭ Prisma generator for generating TypeGraphQL class types and enums with allowing to edit the generated output without being overwritten 💪
Stars: ✭ 32 (-37.25%)
Mutual labels:  generator
lowcode
React Lowcode - prototype, develop and maintain internal apps easier
Stars: ✭ 32 (-37.25%)
Mutual labels:  generator
nest-js-boilerplate
Nest.js boilerplate
Stars: ✭ 79 (+54.9%)
Mutual labels:  generator

built_bloc

Generate the BLoC pattern boilerplate.

Why ?

After using the BLoC pattern a little, it seems pretty cool for sharing code and separation of concerns, but I quickly found myself to write a lot of repetitive boilerplate code : I felt the need for a generator to assist me.

Here is a simple vanilla bloc example which obviously highlights repeated patterns while declaring subjects, streams, sinks and subscriptions.

class VanillaExampleBloc {

  Sink<void> get reset => this._reset.sink;

  Sink<int> get add => this._add.sink;

  Stream<int> get count => this._count.stream;

  final PublishSubject<int> _add = PublishSubject<int>();

  final PublishSubject<void> _reset = PublishSubject<void>();

  final BehaviorSubject<int> _count = BehaviorSubject<int>.seeded(0);

  List<StreamSubscription> subscriptions;

  List<Subject> subjects;

  VanillaExampleBloc() {
    subscriptions = [
      this._add.listen(_onAdd),
      this._reset.listen(_onReset),
    ];
    subjects = [
      this._add,
      this._count,
      this._reset,
    ];
  }

  void _onAdd(int value) {
    this._count.add(this._count.value + value);
  }

  void _onReset(int value) {
    this._count.add(0);
  }

  @mustCallSuper
  void dispose() {
    this.subjects.forEach((s) => s.close());
    this.subscriptions.forEach((s) => s.cancel());
  }
}

With built_bloc, you can replace all of that with just a few lines of code :

@bloc
class ExampleBloc extends Bloc with _ExampleBloc {
  @stream
  final BehaviorSubject<int> _count = BehaviorSubject<int>(seedValue: 0);

  @sink
  @Bind("_onAdd")
  final PublishSubject<int> _add = PublishSubject<int>();

  @sink
  @Bind("_onReset")
  final PublishSubject<void> _reset = PublishSubject<void>();

  void _onAdd(int value) {
    this._count.add(this._count.value + value);
  }

  void _onReset() {
    this._count.add(0);
  }
}

How to use ?

See the built_bloc_generator package.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].