Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
simc committed Dec 22, 2019
1 parent 6a2b34d commit 02cb126
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/src/box/lazy_box.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,13 @@ part of hive;
/// [LazyBox]es don't keep the values in memory like normal boxes. Each time a
/// value is read, it is loaded from the backend.
abstract class LazyBox<E> extends BoxBase<E> {
/// Returns the value associated with the given [key]. If the key does not
/// exist, `null` is returned.
///
/// If [defaultValue] is specified, it is returned in case the key does not
/// exist.
Future<E> get(dynamic key, {E defaultValue});

/// Returns the value associated with the n-th key.
Future<E> getAt(int index);
}
7 changes: 7 additions & 0 deletions lib/src/object/hive_collection.dart
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
part of hive;

abstract class HiveCollection<E extends HiveObject> implements List<E> {
/// The box which contains all the objects in this collection
BoxBase get box;

/// The keys of all the objects in this collection.
Iterable<dynamic> get keys;

/// Delete all objects in this collection from Hive.
Future<void> deleteAllFromHive();

/// Delete the first object in this collection from Hive.
Future<void> deleteFirstFromHive();

/// Delete the last object in this collection from Hive.
Future<void> deleteLastFromHive();

/// Delete the object at [index] from Hive.
Future<void> deleteFromHive(int index);

/// Converts this collection to a Map.
Map<dynamic, E> toMap();
}
4 changes: 4 additions & 0 deletions lib/src/object/hive_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ part of hive;
@experimental
abstract class HiveList<E extends HiveObject> extends HiveCollection<E>
implements List<E> {
/// Create a new HiveList which can contain HiveObjects from [box].
factory HiveList(Box box, {List<E> objects}) =>
HiveListImpl(box, objects: objects);

/// Disposes this list. It is important to call this method when the list is
/// no longer used to avoid memory leaks.
void dispose();

/// Casts the list to a new HiveList.
HiveList<T> castHiveList<T extends HiveObject>();
}
2 changes: 1 addition & 1 deletion lib/src/object/hive_list_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ class HiveListImpl<E extends HiveObject>
if (obj == null) {
throw HiveError('HiveLists must not contain null elements.');
} else if (obj.box != box) {
throw HiveError('The HiveObject needs to be in the box "$boxName".');
throw HiveError('HiveObjects needs to be in the box "$boxName".');
}
}

Expand Down

0 comments on commit 02cb126

Please sign in to comment.