Skip to content
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

Stronger trigger-fire typing #34

Open
samskiter opened this issue Feb 4, 2015 · 2 comments
Open

Stronger trigger-fire typing #34

samskiter opened this issue Feb 4, 2015 · 2 comments

Comments

@samskiter
Copy link

Hi, is it possible to have the trigger firing be more strongly typed/parameterised?

Specifically - to the params provided. It would be nice to force using of a certain number and type of args for a particular trigger. As I understand, currently I can 'fire' with or without any params. I then need to deal with that in my onEntryBlocks

I had a think about how you might achieve this:

  1. After making a TriggerWithParameters - you call a method on it to generate a concrete instance of the trigger. I.e. you have a trigger factory of sorts that you use to get triggers when firing events. This way, you can only fire an event if you made a trigger the 'right' way.
  2. Use a reflection method similar to Retrofit. Supply an interface of events that is parsed down into TriggerWithParameters objects. This might be a Java 8 only option because to configure the onEntryBlock you might have to use a method refs to identify the event methods.
@samskiter
Copy link
Author

Update: I've just found the setTriggerParameters method which allows what I proposed in option 1. This might be a good case for some more example code/docs.

Perhaps making the constructor of TriggerWithParameters package-private might help - I was instantiating one myself, which I don't think is the intended use...

@Ktar5
Copy link
Contributor

Ktar5 commented Feb 19, 2018

I agree, this should be in the documentation. I might write something up on this later today.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants