Giter Site home page Giter Site logo

flutter-dart-open-source / rx_storage Goto Github PK

View Code? Open in Web Editor NEW
9.0 3.0 2.0 122 KB

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

Home Page: https://github.com/hoc081098

License: MIT License

Dart 100.00%
rxdart rxdart-flutter rxdart-bloc rx-storage rxstorage reactive-storage flutter-rx-storage flutter-reactive flutter-reactive-storage rx-shared-preferences

rx_storage's Introduction

rx_storage alt text

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

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

Buy Me A Coffee

Pub Version Pub Version codecov Dart CI License: MIT Style

Note: rx_shared_preferences is an extension of this package.

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.

rx_storage's People

Contributors

hoc081098 avatar renovate-bot avatar renovate[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

rx_storage's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/dart.yml
  • actions/checkout v4
  • dart-lang/setup-dart v1.4
  • codecov/codecov-action v3.1.6
pub
pubspec.yaml
  • rxdart_ext ^0.2.1
  • disposebag ^1.5.1
  • stack_trace ^1.10.0
  • lints ^1.0.1
  • test ^1.17.12
  • collection ^1.16.0
  • dart >=2.12.0 <4.0.0

  • Check this box to trigger a request for Renovate to run again on this repository

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.