Open ryardley opened 5 years ago
The subscription filtering syntax should be abstracted. At the moment, the bus is exposing the syntax of eventemitter2 lib directly to the developer. Replacing eventemitter2 would lead to breaking chances
We don’t have to do this but what do you think about providing a predicate function as the main subscription filtering method and then writing a helper lib that uses a template literal tag function to process the wildcard syntax?
bus.subscribe(t`todos.**`, handler);
Yes, that's what I meant by abstracting. E.g. turning the string into something that can be understood by eventemitter2 or in future extending/adapting to any other other pub/sub component.
But what would be nice actually is to have a type-safer way defining the subscriptions. E.g. I can provide a list of list of events that I am listening to etc. The nice thing about that is that I can easily follow references during code/design time and see where certain events are been "used". Maybe there is a nice way combining this with the string-based approach using string interpolation. Just thinking out loud.
@dmicic Care to throw down a syntax proposal?
Why?