Skip to content

Commit

Permalink
chore: ensure unsubscribed
Browse files Browse the repository at this point in the history
  • Loading branch information
rossbulat committed Nov 7, 2024
1 parent 66c08f9 commit 42901d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/model/Observables/ChainSpec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ export class ChainSpec implements ObservableGetSubscription {

// Handle subscription failure.
const error = async () => {
this.unsubscribe();
reject(null);
};

// Handle completion.
const complete = async () => {
this.unsubscribe();
resolve(this.#value);
};

Expand Down Expand Up @@ -68,6 +70,7 @@ export class ChainSpec implements ObservableGetSubscription {

this.#unsub = subscription.unsubscribe;
} catch (e) {
this.unsubscribe();
reject(null);
}
});
Expand Down
3 changes: 3 additions & 0 deletions src/model/Observables/TaggedMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,13 @@ export class TaggedMetadata implements ObservableGetSubscription {

// Handle subscription failure.
const error = async () => {
this.unsubscribe();
reject(null);
};

// Handle completion.
const complete = async () => {
this.unsubscribe();
resolve(this.#value);
};

Expand Down Expand Up @@ -68,6 +70,7 @@ export class TaggedMetadata implements ObservableGetSubscription {

this.#unsub = subscription.unsubscribe;
} catch (e) {
this.unsubscribe();
reject(null);
}
});
Expand Down

0 comments on commit 42901d1

Please sign in to comment.