Skip to content

Commit

Permalink
API cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danReynolds committed Sep 3, 2024
1 parent faebea2 commit b2460b6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/broadcast_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class BroadcastManager {
}

final pendingEvent = eventStore.get(path);
// Ignore writing a duplicate events or overwriting a pending mutative event type with a touched event.
// Ignore writing a duplicate event or overwriting a pending mutative event type with a touched event.
if (pendingEvent == null ||
(event != pendingEvent && event != BroadcastEvents.touched)) {
eventStore.write(path, event);
Expand Down
2 changes: 2 additions & 0 deletions lib/broadcast_observer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ mixin BroadcastObserver<T, S> {
return _changeController.stream;
}

bool get isDirty;

T? get _value {
return Loon._instance.broadcastManager.observerValueStore.get(_observerId);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/observable_document.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ class ObservableDocument<T> extends Document<T>
}
}

@override
get isDirty => _value == null && super.get() != null;

@override
ObservableDocument<T> observe({
bool multicast = false,
Expand All @@ -94,7 +97,7 @@ class ObservableDocument<T> extends Document<T>

@override
get() {
return _value ?? (_value = super.get());
return isDirty ? (_value = super.get()) : _value;
}

Map inspect() {
Expand Down
5 changes: 4 additions & 1 deletion lib/observable_query.dart
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,12 @@ class ObservableQuery<T> extends Query<T>
return this;
}

@override
get isDirty => _value == null;

@override
get() {
return _value ?? (_value = super.get());
return isDirty ? (_value = super.get()) : _value!;
}

Map inspect() {
Expand Down

0 comments on commit b2460b6

Please sign in to comment.