Closed slice closed 10 months ago
It might be better to expose an event emitter […]
I also just realized that this would also let us separate out guild handling instead of letting it interleave with the rest of the code, which would be really nice. This seems like a good idea, although it might involve priority-related tricks
OK, did a small change to expose new Gateway messages via EventEmitter
and performed a simple move of all handling code into separate files that export functions to attach these handlers.
I did improve the type annotations a little but I had to stop myself from doing a more comprehensive revamp. That can be in a separate PR (#15)
:shipit:
It's fairly unergonomic to have all (~530 LoC) of the high-level Gateway event handling code in
network-api.ts
, so I think it's a good idea to move them into separate files.For now I've just moved the handling for
READY
only, but I plan to structure this more elaborately to make it easy to navigate.I'm not too sure about having them exist as free functions that receive a class instance, as that's really not too different from a method (it's literally just split off). It might be better to expose an event emitter—and then we could even separate the "update internal state" logic and "send server events up to Texts" logic (?)