3 ms·
I 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 u
by valand 7y ago
I 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.