Im triing to design API for library that will allow to subscribe for some events (more like state updates so first massage will by current state and other partial updates of it, but I’m trying to keep it simple so it can be one kind of event) and I’m struggling since there are more options:
- behaviour (what if client want to start subscription dynamicali?)
- send message to pid (like HTTPoison async request handling, but absence of type check in this case make me uncomfortable, also is starting process out of supervision tree and link it to current process)
- create subscribe function that accepts module and function as arguments and call them on every event (allow library to have own supervision tree and use response from function to control subscription, but again, absence of typecheck)
What would you recommend and why?