Skip to content

Commit

Permalink
new: version: 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
PackRuble committed Apr 10, 2023
1 parent 3889e96 commit 27f85c9
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 77 deletions.
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@

[//]: # (todo: The documentation needs a serious update!)

## How to started?

1. Identify the DB object with the necessary mixins (optional)
Expand Down Expand Up @@ -190,13 +192,15 @@ class KeyStore2<T> implements RKey<T> {
## TODO
1. [ ] Add info about watchers
2. [ ] Add info about operation instrument
3. [ ] Add info about convertes and complex objects
3. [ ] Add info about converters and complex objects
4. [ ] Add info about supported types
5. [ ] Add info uses maigrator
5. [ ] Add info uses migrator

## TODO implement
1. [ ] To implement the work of the key migrator.
2. [ ] To implement other converters, e.g. DateTimeConverter
1. [ ] Migrator of data
2. [ ] To implement other converters, e.g. DateTimeConverter, Color, Enum, Map, Set
3. [ ] Tests
4. [ ] License

## Additional information

Expand Down
7 changes: 7 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
include: package:lint/strict.yaml

linter:
rules:
unawaited_futures: true
always_use_package_imports: false
sort_pub_dependencies: false
44 changes: 22 additions & 22 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ packages:
dependency: "direct main"
description:
name: flutter_riverpod
sha256: "371f6e8acb69dbe8aa3e0a50c8a65f8a9352b599134d585cc4923261cb5ae4d6"
sha256: "812dfbb87af51e73e68ea038bcfd1c732078d6838d3388d03283db7dec0d1e5f"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.3.4"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -100,10 +100,10 @@ packages:
dependency: "direct dev"
description:
name: lint
sha256: "4a539aa34ec5721a2c7574ae2ca0336738ea4adc2a34887d54b7596310b33c85"
sha256: "3e9343b1cededcfb1e8b40d0dbd3592b7a1c6c0121545663a991433390c2bc97"
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "2.0.1"
matcher:
dependency: transitive
description:
Expand All @@ -121,7 +121,7 @@ packages:
source: hosted
version: "0.2.0"
meta:
dependency: "direct dev"
dependency: transitive
description:
name: meta
sha256: "6c268b42ed578a53088d834796959e4a1814b5e9e164f147f580a386e5decf42"
Expand Down Expand Up @@ -190,71 +190,71 @@ packages:
path: ".."
relative: true
source: path
version: "0.0.1"
version: "0.1.1"
riverpod:
dependency: transitive
description:
name: riverpod
sha256: "899cd0999b2f3b798349d9b5639cfea81d406c011bd914097145ff92e91b29f9"
sha256: "77ab3bcd084bb19fa8717a526217787c725d7f5be938404c7839cd760fdf6ae5"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.3.4"
shared_preferences:
dependency: transitive
description:
name: shared_preferences
sha256: ee6257848f822b8481691f20c3e6d2bfee2e9eccb2a3d249907fcfb198c55b41
sha256: "858aaa72d8f61637d64e776aca82e1c67e6d9ee07979123c5d17115031c1b13b"
url: "https://pub.dev"
source: hosted
version: "2.0.18"
version: "2.1.0"
shared_preferences_android:
dependency: transitive
description:
name: shared_preferences_android
sha256: "8e251f3c986002b65fed6396bce81f379fb63c27317d49743cf289fd0fd1ab97"
sha256: "8304d8a1f7d21a429f91dee552792249362b68a331ac5c3c1caf370f658873f6"
url: "https://pub.dev"
source: hosted
version: "2.0.14"
version: "2.1.0"
shared_preferences_foundation:
dependency: transitive
description:
name: shared_preferences_foundation
sha256: "6b84fdf06b32bb336f972d373cd38b63734f3461ba56ac2ba01b56d052796259"
sha256: cf2a42fb20148502022861f71698db12d937c7459345a1bdaa88fc91a91b3603
url: "https://pub.dev"
source: hosted
version: "2.1.4"
version: "2.2.0"
shared_preferences_linux:
dependency: transitive
description:
name: shared_preferences_linux
sha256: "28aefc1261746e7bad3d09799496054beb84e8c4ffcdfed7734e17b4ada459a5"
sha256: "9d387433ca65717bbf1be88f4d5bb18f10508917a8fa2fb02e0fd0d7479a9afa"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.2.0"
shared_preferences_platform_interface:
dependency: transitive
description:
name: shared_preferences_platform_interface
sha256: da9431745ede5ece47bc26d5d73a9d3c6936ef6945c101a5aca46f62e52c1cf3
sha256: fb5cf25c0235df2d0640ac1b1174f6466bd311f621574997ac59018a6664548d
url: "https://pub.dev"
source: hosted
version: "2.1.0"
version: "2.2.0"
shared_preferences_web:
dependency: transitive
description:
name: shared_preferences_web
sha256: a4b5bc37fe1b368bbc81f953197d55e12f49d0296e7e412dfe2d2d77d6929958
sha256: "74083203a8eae241e0de4a0d597dbedab3b8fef5563f33cf3c12d7e93c655ca5"
url: "https://pub.dev"
source: hosted
version: "2.0.4"
version: "2.1.0"
shared_preferences_windows:
dependency: transitive
description:
name: shared_preferences_windows
sha256: "97f7ab9a7da96d9cf19581f5de520ceb529548498bd6b5e0ccd02d68a0d15eba"
sha256: "5e588e2efef56916a3b229c3bfe81e6a525665a454519ca51dbcc4236a274173"
url: "https://pub.dev"
source: hosted
version: "2.1.1"
version: "2.2.0"
sky_engine:
dependency: transitive
description: flutter
Expand Down
6 changes: 2 additions & 4 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ dependencies:
reactive_db:
path: '../../reactive_db'

flutter_riverpod: ^2.1.1
flutter_riverpod: ^2.3.4

dev_dependencies:
flutter_test:
sdk: flutter

lint: ^1.10.0

meta: ^1.8.0
lint: ^2.0.1

flutter:
uses-material-design: true
1 change: 1 addition & 0 deletions lib/reactive_db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ library reactive_db;
export 'src/config_db.dart';
export 'src/converter.dart';
export 'src/core.dart';
export 'src/custom_converters.dart';
export 'src/i_card.dart';
export 'src/operation.dart';
export 'src/watcher.dart';
2 changes: 1 addition & 1 deletion lib/src/custom_converters.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'dart:ui';
import 'dart:ui' show Color;

import 'converter.dart';

Expand Down
10 changes: 4 additions & 6 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,20 @@
name: reactive_db # card_db? kartoteka_db
description: A reactive db with handy use - wrapper of shared preferences.
version: 0.0.1
version: 0.1.1

environment:
sdk: '>=2.18.4 <3.0.0'
# flutter: ">=1.17.0"
sdk: '>=2.17.0 <3.0.0'

dependencies:
flutter:
sdk: flutter

shared_preferences: ^2.0.18
state_notifier: ^0.7.2+1
shared_preferences: ^2.1.0
meta: ^1.8.0 # change after bump flutter_test

dev_dependencies:
flutter_test:
sdk: flutter

riverpod: ^2.3.0
riverpod: ^2.3.4
lint: ^2.0.1
36 changes: 22 additions & 14 deletions test/reactive_db_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,17 @@ import 'package:shared_preferences/shared_preferences.dart';

/// Storage of [Enum] type with possibility of using custom key.
enum FruitCard<T> implements ICard<T> {
banana<int>(TypeData.int, 4),
counter1<int>(TypeData.int, 0),
counter2<int>(TypeData.int, 0),
counterCustom<int>(TypeData.int, 2, 'custom_counter_key'),
banana<int>(DataType.int, 4),
bananaNull<int?>(DataType.int, 4),
counter1<int>(DataType.int, 0),
counter2<int>(DataType.int, 0),
counterCustom<int>(DataType.int, 2, 'custom_counter_key'),
;

const FruitCard(this.type, this.defaultValue, [this.customKey]);

@override
final TypeData type;
final DataType type;

@override
final T defaultValue;
Expand All @@ -23,24 +24,26 @@ enum FruitCard<T> implements ICard<T> {

@override
String get key => customKey ?? EnumName(this).name;

@override
CardConfig get config => CardConfig(name: 'FruitCard');
}

class DbUser extends CardDb with Watcher {
DbUser({required super.cards});
DbUser({required super.cards, required super.config});
}

final dbProvider = Provider<DbUser>((ref) => DbUser(cards: FruitCard.values));
final dbProvider = Provider<DbUser>(
(ref) => DbUser(
cards: FruitCard.values,
config: const ConfigDB(name: 'FruitCard'),
),
);

const initCountBanana = 0;

final bananaProvider = Provider<int>((ref) {
ref.watch(dbProvider).attach<int>(
FruitCard.banana,
(value) => ref.state = value,
ref.onDispose,
detacher: ref.onDispose,
);

return initCountBanana;
Expand All @@ -50,7 +53,7 @@ final bananaProviderWithAutoDispose = Provider.autoDispose<int>((ref) {
final banana = ref.watch(dbProvider).attach<int>(
FruitCard.banana,
(value) => ref.state = value,
ref.onDispose,
detacher: ref.onDispose,
);

return banana;
Expand All @@ -63,7 +66,10 @@ void main() {
SharedPreferences.setMockInitialValues({});

test('Watcher', () async {
final db = DbUser(cards: FruitCard.values);
final db = DbUser(
cards: FruitCard.values,
config: const ConfigDB(name: 'FruitCard'),
);

await db.init();

Expand All @@ -72,6 +78,7 @@ void main() {
final int value = db.attach(
FruitCard.banana,
(v) => newValue = v,
detacher: null,
);
expect(
db.debugGetWatchers(),
Expand All @@ -97,7 +104,8 @@ void main() {
expect(
newValue,
newCount,
reason: 'after call [DbCard.set] + before [Watcher.attach], we expect notify',
reason:
'after call [DbCard.set] + before [Watcher.attach], we expect notify',
);
});

Expand Down
15 changes: 7 additions & 8 deletions test/set_get_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,28 @@ import 'dart:ui';

import 'package:flutter_test/flutter_test.dart';
import 'package:reactive_db/reactive_db.dart';
import 'package:shared_preferences/shared_preferences.dart';

import 'source/forest_key_store.dart';

class ForestDb extends CardDb {
ForestDb({required super.cards});
const ForestDb({required super.cards, required super.config});
}

void main() {
SharedPreferences.setMockInitialValues({});
const db = ForestDb(
cards: ForestCard.values,
config: forestCardConfig,
);

db.setMockInitialValues({});

test('Simple getting/setting by Enum.key', () async {
// we may to call ForestDb() - it's the same thing
final db = ForestDb(cards: ForestCard.values);

await db.init();

// Simple reading by key
for (final key in ForestCard.values) {
// if (key == ForestCard.keepAcaciaWithNull) {
// db.getOrNull(key);
// continue;
// }
db.getOrNull(key);
}

Expand Down
Loading

0 comments on commit 27f85c9

Please sign in to comment.