Skip to main content

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

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

example/rx_storage_example.dart

import 'package:rx_storage/rx_storage.dart';

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

  try {
    final key = 'key';
    rxStorage
        .observe(key, (v) => v as String?)
        .listen((String? s) => print('[Observe 1] Value: $s'));
    rxStorage
        .observe(key, (v) => v as String?)
        .listen((String? s) => print('[Observe 2] Value: $s'));
    rxStorage
        .observeAll((key, raw) => raw == null ? null : '$key=$raw')
        .listen((values) => print('[Observe all] Values: $values'));

    await Future<void>.delayed(const Duration(milliseconds: 1));
    print('--- START ---');

    await rxStorage.write(key, '<<1>>', (v) => v);
    print('Read: ${await rxStorage.read(key, (v) => v as String?)}');
    print('-' * 80);

    await rxStorage.write(key, '<<2>>', (v) => v);
    print('Read: ${await rxStorage.read(key, (v) => v as String?)}');
    print('Read all: ${await rxStorage.readAll(
      (_, raw) => raw as String?,
    )}');
    print('-' * 80);

    await rxStorage.remove(key);
    print('Read: ${await rxStorage.read(key, (v) => v as String?)}');
    print('-' * 80);

    await Future<void>.delayed(const Duration(milliseconds: 500));
  } finally {
    await rxStorage.dispose();
  }
}
8
likes
160
points
7.55k
downloads
screenshot

Documentation

API reference

Publisher

verified publisherhoc081098.dev

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

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