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

feat!: make action events more like other events #161

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

tonyandrewmeyer
Copy link
Collaborator

This adjusts emitting action events to align with emitting other events.

When needing to pass params, instead of having to create an Action object, these can just be passed in the run call in the same way that extra parameters for notices, relations, etc are. When using params, the code is about the same size - when there are no parameters it's a little longer than just having a string, but much more consistent, both with the other events, and with using observe.

Example:

# Non-action event
ctx = Context(MyCharm)
ctx.run(ctx.on.start(), State())

# Action event, no params
ctx = Context(MyCharm)
ctx.run(ctx.on.action("foo"), State())

# Action event, params
ctx = Context(MyCharm)
ctx.run(ctx.on.action("foo", params={"bar": 123}), State())

@tonyandrewmeyer tonyandrewmeyer merged commit 15a92b2 into canonical:7.0 Jul 24, 2024
2 checks passed
@tonyandrewmeyer tonyandrewmeyer deleted the align-action-events branch July 24, 2024 05:20
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

Successfully merging this pull request may close these issues.

2 participants