All Projects → mono0926 → Bloc_provider

mono0926 / Bloc_provider

Licence: mit
Provides bloc to descendant widget (O(1)), and the bloc is disposed appropriately by state that the bloc_provider holds internally.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Bloc provider

Star Wars Shop
Simple project with clean architecture and android lifecycle
Stars: ✭ 37 (-68.1%)
Mutual labels:  lifecycle
Jetpackmvvm
🐔🏀一个Jetpack结合MVVM的快速开发框架,基于MVVM模式集成谷歌官方推荐的JetPack组件库:LiveData、ViewModel、Lifecycle、Navigation组件 使用Kotlin语言,添加大量拓展函数,简化代码 加入Retrofit网络请求,协程,帮你简化各种操作,让你快速开发项目
Stars: ✭ 1,100 (+848.28%)
Mutual labels:  lifecycle
Lambcycle
🐑🛵 A declarative lambda middleware with life cycle hooks 🐑🛵
Stars: ✭ 88 (-24.14%)
Mutual labels:  lifecycle
Readhubclient
Readhub客户端
Stars: ✭ 44 (-62.07%)
Mutual labels:  lifecycle
S Mvp
🔥🔥优化版MVP,使用注解泛型简化代码编写,使用模块化协议方便维护,APT过程使用注解解析器利用JavaPoet🌝完成重复模块的编写,利用ASpect+GradlePlugin 完成横向AOP编程+Javassist动态字节码注入+Tinker实现热修复+Retrofit实现优雅网络操作+RxJava轻松玩转数据处理
Stars: ✭ 1,095 (+843.97%)
Mutual labels:  lifecycle
Aacomponents
基于google Android Architecture Components 封装实现组件式MVP快速开发框架
Stars: ✭ 66 (-43.1%)
Mutual labels:  lifecycle
Mvvmhabitcomponent
👕基于MVVMHabit框架,结合阿里ARouter打造的一套Android MVVM组件化开发方案
Stars: ✭ 857 (+638.79%)
Mutual labels:  lifecycle
Aachulk
️🔥️🔥️🔥AACHulk是以Google的ViewModel+DataBinding+LiveData+Lifecycles框架为基础, 结合Okhttp+Retrofit+BaseRecyclerViewAdapterHelper+SmartRefreshLayout+ARouter打造的一款快速MVVM开发框架
Stars: ✭ 109 (-6.03%)
Mutual labels:  lifecycle
Buildplan Maven Plugin
A Maven 3.x plugin to inspect project lifecyle.
Stars: ✭ 57 (-50.86%)
Mutual labels:  lifecycle
Postinstall Build
Helper for conditionally building your npm package on postinstall
Stars: ✭ 87 (-25%)
Mutual labels:  lifecycle
Rxlifecycle
🐹 Easy life cycle observation
Stars: ✭ 46 (-60.34%)
Mutual labels:  lifecycle
Tdcapp
Sample app which access the TDC (The Developer's Conference) REST API.
Stars: ✭ 55 (-52.59%)
Mutual labels:  lifecycle
Annotationkit
The annotation implementation using Objective-C
Stars: ✭ 68 (-41.38%)
Mutual labels:  lifecycle
Wanandroid
Jetpack MVVM For Wanandroid 最佳实践 !
Stars: ✭ 1,004 (+765.52%)
Mutual labels:  lifecycle
Lazybones
😴 A super lazy and fluent Kotlin expressions for initializing lifecycle-aware property.
Stars: ✭ 91 (-21.55%)
Mutual labels:  lifecycle
Recycles
React lifecycle render-prop components ♻️
Stars: ✭ 15 (-87.07%)
Mutual labels:  lifecycle
Easychatandroidclient
EasyChat是一个开源的社交类的App。主要包含消息、好友、群组等相关的IM核心功能。部分界面参照了QQ、微信等相关社交APP。EasyChat APP整体采用MVVM模式,基于JetPack(Lifecycle,LiveData,ViewModel,Room)构建
Stars: ✭ 64 (-44.83%)
Mutual labels:  lifecycle
Mvvm Architecture
The practice of MVVM + Jetpack architecture in Android.
Stars: ✭ 1,634 (+1308.62%)
Mutual labels:  lifecycle
Neteasecloudmusic Mvvm
Jetpack MVVM最佳实践 - 重构仿网易云音乐安卓客户端
Stars: ✭ 103 (-11.21%)
Mutual labels:  lifecycle
Retrofitlifecycle
Manage retrofit call's lifecycle with proxy class which generated by annotation
Stars: ✭ 81 (-30.17%)
Mutual labels:  lifecycle

bloc_provider Codemagic build status

Provides BLoC(Business Logic Component) to descendant widget (O(1)), and the bloc is disposed automatically by the state which the bloc_provider holds internally.

Recommended other packages

bloc_provider was one of the good choice for BLoC pattern until early 2019, but I now recommend to use these instead.

bloc_provider will now be minimally maintained.

Usage

1. Define some BLoC like this:

class CounterBloc implements Bloc {
  final _countController = BehaviorSubject<int>.seeded(0);
  final _incrementController = PublishSubject<void>();

  CounterBloc() {
    _incrementController
        .scan<int>((sum, _v, _i) => sum + 1, 0)
        .pipe(_countController);
  }

  ValueStream<int> get count => _countController;
  Sink<void> get increment => _incrementController.sink;

  @override
  void dispose() async {
    await _incrementController.close();
    await _countController.close();
  }
}

2. Provide the bloc by using BlocProvider and access the bloc at subtree:

void main() => runApp(
      // Create and provide the bloc.
      BlocProvider<CounterBloc>(
        creator: (_context, _bag) => CounterBloc(),
        child: App(),
      ),
    );

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // Access the bloc with O(1) computation complexity.
    final bloc = BlocProvider.of<CounterBloc>(context);
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: StreamBuilder<int>(
            stream: bloc.count,
            initialData: bloc.count.value,
            builder: (context, snap) => Text(
                  'count: ${snap.data}',
                  style: Theme.of(context).textTheme.title,
                ),
          ),
        ),
        floatingActionButton: FloatingActionButton(
          child: const Icon(Icons.add),
          onPressed: () => bloc.increment.add(null),
        ),
      ),
    );
  }
}
  • Computational complexity of of method, which is used for accessing the bloc is O(1).
  • Provided bloc will be disposed when the inner state is disposed 👍

Examples

Technical explanation

Features and bugs

Please file feature requests and bugs at the issue tracker.

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].