rx_storage 3.0.0 copy "rx_storage: ^3.0.0" to clipboard
rx_storage: ^3.0.0 copied to clipboard

Reactive storage for Dart/Flutter. RxDart Storage for Dart/Flutter.

rx_storage alt text #

Reactive storage for Dart/Flutter. RxDart Storage for Dart/Flutter.

rx_shared_preferences is an extension of this package, check it out! #

Author: Petrus Nguyễn Thái Học #

Pub Version Pub Version codecov Dart CI Hits License: MIT Style

RxDart

Liked some of my work? Buy me a coffee (or more likely a beer).

Buy Me A Coffee

More detail about returned Stream #

  • It's a single-subscription Stream (ie. it can only be listened once).

  • Stream will emit the value (nullable) or a TypeError as its first event when it is listen to.

  • It will automatically emit value when value associated with key was changed successfully (emit null when value associated with key was removed or set to null).

  • When value read from Storage has a type other than expected type:

    • If value is null, the Stream will emit null (this occurred because null can be cast to any nullable type).
    • Otherwise, the Stream will emit a TypeError.
  • Can emit two consecutive data events that are equal. You should use Rx operator like distinct (More commonly known as distinctUntilChanged in other Rx implementations) to create an Stream where data events are skipped if they are equal to the previous data event.

Key changed:  |----------K1---K2------K1----K1-----K2---------> time
              |                                                
Value stream: |-----@----@------------@-----@-----------------> time
              |    ^                                      
              |    |
              |  Listen(key=K1)
              |
              |  @: nullable value or TypeError

Usage #

A simple usage example:

import 'package:rx_storage/rx_storage.dart';

class StorageAdapter implements Storage<String, void> { ... }

main() async {
  final adapter = StorageAdapter();
  final rxStorage = RxStorage<String, void>(adapter);

  rxStorage.observe('key', (v) => v as String?).listen((String? s) { ... });
  await rxStorage.write('key', 'a String', (v) => v);
  await rxStorage.read('key', (v) => v as String?);
}

Features and bugs #

Please file feature requests and bugs at the issue tracker.

7
likes
160
points
4.25k
downloads
screenshot

Publisher

unverified uploader

Weekly Downloads

Reactive storage for Dart/Flutter. RxDart Storage for Dart/Flutter.

Repository (GitHub)
View/report issues

Topics

#rxdart #hoc081098 #rx-storage #reactive-storage #reactive-programming

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (license)

Dependencies

disposebag, meta, rxdart_ext, stack_trace

More

Packages that depend on rx_storage