element-hq / element-web

A glossy Matrix collaboration client for the web.
https://element.io
GNU Affero General Public License v3.0
11.19k stars 2k forks source link

Improve event re-emitter logic across codebase #26383

Open MidhunSureshR opened 1 year ago

MidhunSureshR commented 1 year ago

Your use case

What would you like to do?

See https://github.com/matrix-org/matrix-js-sdk/pull/3796

We should examine if this sort of issue happens in other parts of the codebase.

Why would you like to do it?

Lots of potential to cause bugs. We should have a better way of listening to changes on objects that isn't based on manually setting up re-emitter logic.

How would you like to achieve it?

Requires deliberation, but observables (eg: https://rxjs.dev/) may make sense. For example, we could have an observable map of users that the memberlist would subscribe to.

Have you considered any alternatives?

No response

Additional context

No response

robintown commented 1 year ago

Big +1 for observables. While our current pattern of using events and raw fields certainly gets the job done, it defies all attempts to capture the pattern in a single type. This leads to a lot of boilerplate, for both data producers, transformers, and consumers, which in turn equals lots of potential for bugs.