-
Notifications
You must be signed in to change notification settings - Fork 0
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
Implement handling of command rejections #86
base: master
Are you sure you want to change the base?
Conversation
…handle-command-rejections
@dpikhulya val command: SomeCommand = someCommand()
val succeeded: Boolean = command.post(
SubscribeTo({
events<ExpectedEvent>(
ExpectedEvent.Field.id(),
command.id
),
rejections<PossibleRejection>(
PossibleRejection.Field.id(),
command.id
) handledAs { ... }
})
) Notice the change in wording. And also, the generic parameter (which you can infer in Kotlin, AFAIK), instead of the first argument. Do I understand correctly that the subscription by any field (not just by |
@dpikhulya another question is why we have this duality in your code: rejection( ... ) handledAs { ... }
// ...
// and then suddenly, again
onRejection { ... } To me this looks like two ways to do the same. And this is somewhat confusing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dpikhulya please see my comments.
@dpikhulya one more thing. Events and rejections in Spine know about their origin via |
# Conflicts: # dependencies.md
This PR generalizes
CommandOutcomeHandler
to a more capableCommandLifecycle
object, which can be configured to handle different kinds of situations that can happen when posting the command:CommandLifecycle
displays a configurable message for them, but it's possible to override this behavior either for all rejections at once, or on a per-rejection basis.By default it displays configurable messages upon either of the "negative" scenarios, but handlers for those scenarios can be customized.
Here are some usage examples (see the KDocs for all configuration parameters):
An example of per-rejection and common (all-rejecctios) custo handling:
Besides, this PR contains:
CommandMessageForm
,CommandWizard
, andCommandDialog
implementations to use the newCommandLifecycle
object instead of the old limited event subscription that they were using up to now.Dialog
'sdialogWidth
/dialogHeight
properties towidth
/height
(to remove the redundancy in naming).