Skip to content
pubscout

angular_bloc

9.0.0, released 4 years ago by bloclibrary.dev

AngularDart components that bind Bloc/Cubit state to the UI via a pipe.

Quiet but busy
$ flutter pub add angular_bloc
Source repository

What it does

Provides a BlocPipe that connects Bloc or Cubit streams to Angular templates, updating the view on state changes. Works with the bloc package to enable BLoC pattern in AngularDart apps.

AI-written summary of version 9.0.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a web app with AngularDart and want to use the Bloc state‑management pattern.
  • You need a simple way to bind Bloc/Cubit state to Angular templates without writing manual subscriptions.

Skip it when

  • Your project is a Flutter app (use flutter_bloc or bloc instead).
  • You require code‑generation or advanced DI features not offered by this package.

Strengths

  • Seamless integration of Bloc with AngularDart via a pipe.
  • Supports both Bloc and Cubit APIs.
  • Minimal boilerplate for UI binding.

Weaknesses

  • Limited to AngularDart/web; not usable in Flutter or mobile contexts.
  • Frequent breaking changes tied to ngdart and bloc version upgrades.

Setup

Kind
Pure Dart
Effort
Medium
Code generation
No
Direct dependencies
2

Add angular_bloc, ngdart and bloc to pubspec, import angular_bloc.dart, and use BlocPipe in component metadata.

import 'package:angular/angular.dart';
import 'package:angular_bloc/angular_bloc.dart';
import 'package:bloc/bloc.dart';

class CounterCubit extends Cubit<int> {
  CounterCubit() : super(0);
  void increment() => emit(state + 1);
}

@Component(
  selector: 'counter-page',
  template: '''
    <h2>Count: {{ $pipe.bloc(counterCubit) }}</h2>
    <button (click)="counterCubit.increment()">+</button>
  ''',
  pipes: [BlocPipe],
)
class CounterPageComponent implements OnInit, OnDestroy {
  late final CounterCubit counterCubit;
  void ngOnInit() => counterCubit = CounterCubit();
  void ngOnDestroy() => counterCubit.close();
}

Alternatives

Packages that do the same job and could replace angular_bloc.

  • yx_state

    A state management library for Dart and Flutter applications.

  • bloc_tools

    Command-line tools for generating and linting bloc and cubit components.

  • rx_bloc

    A BLoC design pattern implementation using reactive streams.

  • riverpod

    A reactive caching and data-binding framework. Riverpod makes working with asynchronous code a breeze.

Works with

Packages commonly used together with angular_bloc: ones it builds on, ones built on it, and its own family.