-
Notifications
You must be signed in to change notification settings - Fork 9
Conversation
const controller = new AbortController(); | ||
const { signal } = controller; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with the AbortController
we don't need a listener ref to remove the listener
subscribeWithStop: ClientSubscribeWithStop<SendE, InternalE> = (message, createListenerCb) => { | ||
const stop = () => { | ||
delete this.pendingSubscriptions[message.id]; | ||
const activeSubscriptionId = this.activeSubscriptionByMessageId[message.id]; | ||
if (activeSubscriptionId) { | ||
delete this.activeSubscriptions[activeSubscriptionId]; | ||
} | ||
}; | ||
this.pendingSubscriptions[message.id] = createListenerCb(stop); | ||
this.call(message); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll rename this to subscribe
and remove the method from line 83
this.activeSubscriptionByMessageId[e.id] = e.result; | ||
} | ||
delete this.pendingSubscriptions[e.id]; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are many if
s here but for subscriptions we need to filter the initialization message so we can setup the listener for the actual subscription messages
this.pendingSubscriptions[id]?.(e); | ||
delete this.pendingSubscriptions[id]; | ||
} | ||
for (const id in this.activeSubscriptions) { | ||
this.activeSubscriptions[id]?.(e); | ||
delete this.activeSubscriptions[id]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as long as the provider communicate any network error through the listeners, this will cover #245 for .call
and .subscribe
Resolves #
Description