Skip to content

Multiple onNotification/onRequest registration #63

Description

@RedGlow

Hello,

I've noticed that the onNotification method for the extension side of the messenger allows for multiple notifications to be registered on the same method, just as onRequest does. They are only later filtered down using the sender when a message is received, and in case multiple handlers exist for a message then an error is raised.

On the webview side instead, one can still have multiple registrations of a notification or request, but they get overwritten, and in a silent way, without logging anything or raising errors. Only the latest registration will be called, and the Disposable object returned by the onNotification/onRequest method will destroy the latest registration always.

I think that at a semantic level there's no problem registering multiple handlers for the same notifications, and they can all be invoked one after the other, while only a single handler should be registered for a request. Overlapping registrations can also be determined at registration time, immediately notifying the client code with an exception in the case of requests. Since this behavior is the same both on the extension and webview side, the core of it could also be factored in one place (maybe something like an abstract class, next to MessengerAPI?). In any case, the situation of silently dropping handlers should never happen, whatever semantics are implemented, and at least a warning/error should be raised.

Is my analysis of the code and reasoning sound?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions