Skip to content

Conversation

@lukecaan
Copy link
Member

@lukecaan lukecaan commented May 15, 2025

See associated UI changes in this PR :: https://github.com/drift-labs/protocol-v2-mono/pull/3593

@lukecaan lukecaan marked this pull request as ready for review May 25, 2025 13:28
}
}

this.subscribeToApi();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i feel sus about this implementation...

we are subscribing to the API on object creation, but we don't have any information about the subscription from the consumer's POV.

e.g. we do const marketDataApiSubscription = new ApiSubscription(...)

but this code don't know anything about the underlying subscription, whereas we'd usually have something like const subscription = await marketDataApiSubscription.subscribe()

Copy link
Member Author

@lukecaan lukecaan Jul 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok coming back to this yeah the idea was that apisubscription IS A SUBSCRIPTION .. it shouldn't exist without a subscriber/without being subscribed .. so it's got a minimal interface where the only public methods available are to add or remove subscribers (and it will automatically unsubscribe when there are no subscribers left) .. I'll wait to see what you think , I don't think it's that bad tbh 🧐


// Check if we've exceeded the maximum reconnect attempts
if (this.reconnectAttempts >= this.maxAttemptsCount) {
throw new Error(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will it break the UI if the UI doesn't catch this error? is it better to just log the error?

@lukecaan lukecaan merged commit df19634 into master Jul 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants