Skip to content

Commit

Permalink
Fix RelayObservable ifEmpty: Cannot access 'current' before initializ…
Browse files Browse the repository at this point in the history
…ation

Reviewed By: alunyov

Differential Revision: D49214158

fbshipit-source-id: 38eb9b75eed5aed34aadaf183887e9a46e033fe1
  • Loading branch information
Jeremy Greenfield authored and facebook-github-bot committed Sep 14, 2023
1 parent 38a08ed commit 33d5475
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/relay-runtime/network/RelayObservable.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,8 @@ class RelayObservable<+T> implements Subscribable<T> {
ifEmpty<U>(alternate: RelayObservable<U>): RelayObservable<T | U> {
return RelayObservable.create(sink => {
let hasValue = false;
let current: Subscription = this.subscribe({
let current: ?Subscription;
current = this.subscribe({
next(value) {
hasValue = true;
sink.next(value);
Expand All @@ -287,7 +288,7 @@ class RelayObservable<+T> implements Subscribable<T> {
},
});
return () => {
current.unsubscribe();
current && current.unsubscribe();
};
});
}
Expand Down

0 comments on commit 33d5475

Please sign in to comment.