Skip to content

Commit

Permalink
fix(database): cache the result of event.snapshot to be able to compa…
Browse files Browse the repository at this point in the history
…re the value (#9899)
  • Loading branch information
Lyokone committed Nov 14, 2022
1 parent cbb24ac commit 5f32b81
Showing 1 changed file with 5 additions and 1 deletion.
Expand Up @@ -16,8 +16,12 @@ class DatabaseEvent {
/// The type of event.
DatabaseEventType get type => _delegate.type;

/// The cached [DataSnapshot] for the event.
DataSnapshot? _dataSnapshot;

/// The [DataSnapshot] for this event.
DataSnapshot get snapshot => DataSnapshot._(_delegate.snapshot);
DataSnapshot get snapshot =>
_dataSnapshot ??= DataSnapshot._(_delegate.snapshot);

/// A string containing the key of the previous sibling child by sort order,
/// or null if it is the first child.
Expand Down

0 comments on commit 5f32b81

Please sign in to comment.