openwallet-foundation / credo-ts

Typescript framework for building decentralized identity and verifiable credential solutions
https://credo.js.org
Apache License 2.0
262 stars 199 forks source link

Event emitter overhaul #247

Open TimoGlastra opened 3 years ago

TimoGlastra commented 3 years ago

Steps

  1. First remove dependency service emitters
  2. Then see how we can remove dependency between modules/services using events

Questions


Links and inspirations: https://herbertograca.com/2017/11/16/explicit-architecture-01-ddd-hexagonal-onion-clean-cqrs-how-i-put-it-all-together/ https://github.com/uport-project/veramo/blob/next/packages/core/src/agent.ts

list of events:

event name conventions:

Connection module needs routing service (how to do with events?)

jakubkoci commented 3 years ago

I was considering having our own EventEmitter API independent of implementation, be it Node.js EventEmitter, RxJS or whatever else. Not sure about that.

One benefit would be a possibility to change the implementation or align the API with our needs (needs of the framework 😄 ) On the contrary, developers would need to understand the API and maybe also the underlying technology. 🤷‍♂️

icc-romeu commented 3 years ago

I think a bit like you @jakubkoci because relying on third-party EventEmitter may break things, at least on mobile implementations, as you cannot have some of these on mobile, like Node.js.

An EventEmitter is just a way of communicating to some other element in the code that wants to be notified. I think it is easy to understand an EventEmitter usage.

Also, creating an implementation of that will help in other features like parallel vs serial, waiting for events to be processed, queues, etc.