Skip to content

Define CommandMessage pattern and implement first messages#6640

Draft
TimoPtr wants to merge 2 commits intomainfrom
feature/external_command_pattern
Draft

Define CommandMessage pattern and implement first messages#6640
TimoPtr wants to merge 2 commits intomainfrom
feature/external_command_pattern

Conversation

@TimoPtr
Copy link
Copy Markdown
Member

@TimoPtr TimoPtr commented Mar 27, 2026

Summary

Come up with a pattern to define with a strong type the Commands that we send to the frontend that uses the command JSON discriminator. Since a sealed class member cannot have twice the same discriminator (otherwise it cannot de-serialize properly), I had to come up with this pattern where we override the invoke operator of an object to keep a nice API.

Checklist

  • New or updated tests have been added to cover the changes following the testing guidelines.
  • The code follows the project's code style and best_practices.
  • The changes have been thoroughly tested, and edge cases have been considered.
  • Changes are backward compatible whenever feasible. Any breaking changes are documented in the changelog for users and/or in the code for developers depending on the relevance.

Any other notes

I don't like it but I didn't find any other way for the Payload to be a JsonElement, using a template breaks the serialization engine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant