5 ms·
Simple Strongly-Typed Events
- vitaly-t 7y agoFor anyone looking for a simple strongly-typed events library, I wrote sub-events: https://github.com/vitaly-t/sub-events https://github.com/vitaly-t/sub-events. It requires no time to learn, is quite basic, while still very flexible and well-documented: https://vitaly-t.github.io/sub-events https://vitaly-t.github.io/sub-events. If your project does not need anything advanced, in the likes of Rxjs, or you do not want to invest much time learning it without an actual need, sub-events offers an easy way to get started with strongly-typed events.
- valand 7y agoHey, I've also got one in progress, can we join effort? This includes other modules related to forking events and async processes https://github.com/Kelerchian/florcky https://github.com/Kelerchian/florcky
- vitaly-t 7y agoJoin effort how? I have finished my project, it is complete. I have looked at your project, and it looks like you have bundled events implementation with something else entirely. An event library should probably stand alone in this ;) However, my implementation is a bit more advanced. If you are interested in using sub-events, and have questions - feel free to ask me on GitHub! ;)
- valand 7y agoI do agree that your implementation has less stringly-typed code, which is nice. I'm actually more interested in creating more awareness on how events can be used to communicate between components in-place of shared states. I'm also curious on why did you choose to use class over interface, which is zero-cost, to implement subscription.
- vitaly-t 7y agoBoth Event and Subscription class have their own state to maintain, plus all the methods, so they cannot be interfaces. As for sharing events between components, there is nothing to it, you just expose an event object from the component, so anyone can subscribe.