Skip to content
This repository has been archived by the owner on Apr 13, 2023. It is now read-only.

Commit

Permalink
Ensure subscription state is set before calling onSubscriptionData
Browse files Browse the repository at this point in the history
This will make sure `onSubscriptionData` has access to the most
up to date subscription result.

Relates to #3139.
  • Loading branch information
hwillson committed Jun 21, 2019
1 parent 876286f commit 7aad988
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions packages/hooks/src/data/SubscriptionData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,18 @@ export class SubscriptionData<
private updateCurrentData(result: SubscriptionResult<TData>) {
const { onSubscriptionData } = this.getOptions();

this.updateResult({
data: result.data,
loading: false,
error: undefined
});

if (onSubscriptionData) {
onSubscriptionData({
client: this.refreshClient().client,
subscriptionData: result
});
}

this.updateResult({
data: result.data,
loading: false,
error: undefined
});
}

private updateError(error: any) {
Expand Down

0 comments on commit 7aad988

Please sign in to comment.