value_bloc 0.5.0-dev.6 copy "value_bloc: ^0.5.0-dev.6" to clipboard
value_bloc: ^0.5.0-dev.6 copied to clipboard

discontinued
outdated

A predictable state management library that helps implement a fetch data from database or another storage

value_bloc #

GitHub pub.dev
value_bloc value_bloc
flutter_value_bloc flutter_value_bloc

Getting Started #

ValueBloc and ListBloc allow you to retrieve data from a repository / database and display it on the screen Both blocs allow you to pre-load before showing the data on the screen They also allow you to update data based on a filter and reload data

ValueBloc #

ValueBloc allows you to display a value

class NameValueBloc extends SingleValueBloc<String, Object> {
  // Required loading
  NameValueBloc() : super(isLoading: true);

  void onLoading() {
    // write your code for initializing bloc
    emitLoading();
  }

  void onFetching() {
    // write your code for fetching value
    emitFetched('Mario');
  }
}

void main() {
  final valueBloc = NameBloc();

  valueBloc.listen(print);
  // LoadingSingleValueState
  // LoadedSingleValueState
  // FetchingValueState
  // FetchedValueState(value:'Mario')
}

ListBloc #

ListBloc allows you to view a set of recoverable values from a sql, graph or document database, regardless of the database used it will work

class NamesListBloc extends ListValueCubit<String, Object> {
  NamesListBloc() : super(isFetching: false);

  void onLoading() {
    // write your code for initializing bloc
    emitLoading();
  }

  void onFetching(int offset, [int limit]) {
    // write your code for fetching value
    emitFetchedCount(offset, limit, ['Mario', 'Luigi'], 2);
  }
}

void main() async {
  final valueBloc = NameBloc();

  print(valueBloc.state); // IdleListValueState

  valueBloc.load(); 
  print(await valueBloc.first); // LoadingListValueState
  print(await valueBloc.first); // LoadedListValueState

  valueBloc.fetch(); 
  print(await valueBloc.first); // FetchingListValueState
  print(await valueBloc.first); // FetchedListValueState(values:['Mario','Luigi'])
}
2
likes
0
points
8
downloads

Publisher

unverified uploader

Weekly Downloads

A predictable state management library that helps implement a fetch data from database or another storage

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bloc, built_collection, built_value, collection, equatable, meta, pure_extensions, quiver, rxdart

More

Packages that depend on value_bloc