Skip to content

Commit

Permalink
Merge pull request #592 from dkunzler/265-lazyBox-notify
Browse files Browse the repository at this point in the history
Fix #265
  • Loading branch information
themisir authored Mar 7, 2021
2 parents 2279300 + 1004ab8 commit 266fb5e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions hive/lib/src/box/keystore.dart
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class Keystore<E> {
}

/// Not part of public API
Frame? insert(Frame frame, {bool notify = true}) {
Frame? insert(Frame frame, {bool notify = true, bool lazy = false}) {
var value = frame.value;
Frame? deletedFrame;

Expand All @@ -160,7 +160,7 @@ class Keystore<E> {
value.init(key, _box);
}

deletedFrame = _store.insert(key, frame);
deletedFrame = _store.insert(key, lazy ? frame.toLazy() : frame);
} else {
deletedFrame = _store.delete(frame.key);
}
Expand Down
2 changes: 1 addition & 1 deletion hive/lib/src/box/lazy_box_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LazyBoxImpl<E> extends BoxBaseImpl<E> implements LazyBox<E> {
if (frame.value is HiveObject) {
(frame.value as HiveObject).init(frame.key, this);
}
keystore.insert(frame.toLazy());
keystore.insert(frame, lazy: true);
}

await performCompactionIfNeeded();
Expand Down
4 changes: 2 additions & 2 deletions hive/test/tests/box/lazy_box_impl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ void main() {
Frame('key1', 'value1'),
Frame('key2', 'value2'),
]),
keystore.insert(Frame.lazy('key1')),
keystore.insert(Frame.lazy('key2')),
keystore.insert(Frame('key1', 'value1'), lazy: true),
keystore.insert(Frame('key2', 'value2'), lazy: true),
]);
});

Expand Down
4 changes: 2 additions & 2 deletions hive/test/tests/mocks.mocks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ class MockKeystore<E> extends _i1.Mock implements _i11.Keystore<E> {
_i7.Stream<_i3.BoxEvent> watch({dynamic key}) => (super.noSuchMethod(
Invocation.method(#watch, [], {#key: key}),
Stream<_i3.BoxEvent>.empty()) as _i7.Stream<_i3.BoxEvent>);
_i9.Frame? insert(_i9.Frame? frame, {bool? notify = true}) => (super
.noSuchMethod(Invocation.method(#insert, [frame], {#notify: notify}))
_i9.Frame? insert(_i9.Frame? frame, {bool? notify = true, bool lazy = false}) =>
(super.noSuchMethod(Invocation.method(#insert, [frame], {#notify: notify}))
as _i9.Frame?);
bool beginTransaction(List<_i9.Frame>? newFrames) => (super.noSuchMethod(
Invocation.method(#beginTransaction, [newFrames]), false) as bool);
Expand Down

0 comments on commit 266fb5e

Please sign in to comment.