You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mechanism for removing connection onClose callback #229
We can register a callback with an RSocket using the onClose method. We do not currently have any way to deregister a previously registered callback.
Motivation
I'm sure there are other use cases, however, this would be useful when paired with the useEffect hook in React, which expect to be able to "undo" registrations and side-effects.
RSocket, likely through Closeable, could be extended to allow deregistration of callbacks. This might be best with having Closeable more closely resemble event emitter APIs.
// add a listenerconstid=rsocket.onClose.addEventListener(()=>{...});// remove a listenerrsocket.onClose.removeEventListener(id);
Considered alternatives
Rsocket.onClose could implement/expose an observable that would natively support subscriptions. This could use existing types such as Cancellable and OnTerminalSubscriber.
Activity