value_bloc 0.0.1 copy "value_bloc: ^0.0.1" to clipboard
value_bloc: ^0.0.1 copied to clipboard

discontinued
outdated

ValueBloc

value_bloc #

ValueBloc and PagesBloc

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 ValueBloc<String, Object> {
  NameValueBloc() : super(initialLoadStatus: LoadStatusValueBloc.loading);

  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);
  // ValueBlocState -> loading...
  // ValueBlocState -> loaded
  // ValueBlocState -> fetching...
  // ValueBlocState -> "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 ListBloc<String, Object> {
  NamesListBloc() : super(initialFetchStatus: FetchStatusValueBloc.idle);

  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); // idle...

  valueBloc.load(); 
  print(await valueBloc.first); // loading ...
  print(await valueBloc.first); // loaded

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

Publisher

unverified uploader

Weekly Downloads

ValueBloc

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

bloc, built_collection, built_value, meta

More

Packages that depend on value_bloc