-
-
Notifications
You must be signed in to change notification settings - Fork 324
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create bee Events with less Effort #284
base: master
Are you sure you want to change the base?
Conversation
Bees can now create Events based on the name and a map containing the Placeholders with Names and Values. To do this we use the Event&Placeholder-Descriptor information which given in the Bees Factory Namespace. This will lead to a much shorter declaration of occuring Events in the Bees implementation.
Using the newly implemented CreateEvent-Method which leaves us with less boilerplate code for creating the Weather events.
Another example for the usage of the new CreateEvent method which comes in pretty handy.
df2b01d
to
6e9b6d0
Compare
force pushed some fixed typos in my comments |
It's a matter of preference, but I'm ok with the existing code if that helps. It's explicit, making it easier to understand what kind of types are being sent in each event when reading the code. A bit less magical. |
I agree that the existing code is less magical and also more explicit about the types. Yet the On second thought, I realized that not using the code from this pr would be in favour of the KISS principle - there should be only one consistent way to declare the events (even if it's more verbose). Therefore I'd also say that we should rather not merge this pr. Any final thoughts @muesli? p.s. after looking at the code again I also noticed that I should probably break the loop in |
This adds a new
createEvent()
method on the implemented Bees which handles back a filledEvent
-Struct for the given Eventname and map of Placholder values.The map for the Placeholders should be structured like this:
With a map like this you can simply trigger an event like so:
I also demonstrated the usage in
openweathermapbee/event.go
and in theircbee.go
and as you can see this reduces the amount of code we have to write.