Combine Precondition and object available on the Command
Not sure if I've put that the right way, but I'm sure that the example will make some sense.
I have this precondition that works.
I've used it to replace a bunch of code that I had in several commands that was similar to
The key to my question is on that last line above.... do something with the character object.
To do this when I need to, it means that I need to use
CharacterService.getCharacter
a second time - which if possible, I'd like to avoid.
Almost all of my commands have a context of the character
.
The reason I have it as a precondition is so that I can selectively apply it to the commands, as not all of them need the character.
But enough of them do, that if I can abstract that character up into the command itself, it'll be useful.
Can I do something at the precondition level, to assign something, so that in the command itself, I will have access to the character
?
Otherwise, is there some better way to do this, that is not a precondition?2 Replies
Can I do something at the precondition level, to assign something, so that in the command itself, I will have access to the character?There isnt. Honestly with how many times it's been requested however maybe we should consider adding a
preconditionData: T
or something. Thoughts @vladdy ?
Otherwise, is there some better way to do this, that is not a precondition?Preconditions are just glorified if checks after all. @vladdy
maybe, idk rn
havent had time to think about it