-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add a "ShortcutReader" interface #2025
Add a "ShortcutReader" interface #2025
Conversation
* | ||
* @param shortcut The shortcut | ||
*/ | ||
void of(ShortcutDTO shortcut); |
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.
I'm still thinking whether it is better to add the functionality of this method to the constructor.
Changing the constructor to have the signature:
public ShortcutReader(ShortcutDTO shortcut)
has the benefit that the object usage is cleaner. In addition it has the disadvantage that we can't add the constructor requirement to the interface.
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.
If it is part of the constructor, it cannot be defined in the interface, right?
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.
Exactly
I'm also thinking about whether it makes sense to move the This leads me to a second question, why do we have both a |
I can't really answer this because this functionality has been there before I joined. So this is a question for @qparis. However, I would agree that implementing the |
I have just created #2033, PhoenicisOrg/scripts#1068 and PhoenicisOrg/scripts#1069 to continue the open discussions. I think we can merge this as is, and work on the created issues separately. |
Any news on this? It would be nice if we could merge this before #2050 |
@@ -43,24 +43,30 @@ public void run(ShortcutDTO shortcutDTO, List<String> arguments, Consumer<Except | |||
final InteractiveScriptSession interactiveScriptSession = scriptInterpreter.createInteractiveSession(); | |||
|
|||
interactiveScriptSession.eval("include(\"engines.wine.shortcuts.reader\");", | |||
ignored -> interactiveScriptSession.eval("new ShortcutReader()", output -> { | |||
final Value shortcutReader = (Value) output; | |||
result -> { |
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.
This code is the same everywhere. Can we extract it to a separate method?
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.
My idea was to do this later on in a centralized method in PhoenicisScriptEngine
:
public interface PhoenicisScriptEngine {
<E> E evalAndReturn(String script, Class<E> type);
<E> void eval(String script, Class<E> type, Consumer<E> onSuccess, Consumer<Exception> onError);
}
See also our documentation.
For now I would suggest to retain the redundancy and fix this later for all script types (i.e. engines, installers, plugins, shortcuts, verbs etc.) at once.
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.
I'm fine with that.
You need to resolve some conflicts. |
@plata the conflicts are resolved. I would like to merge this soon because this PR blocks other useful changes to the script engine. |
This PR adds a
ShortcutReader
interface for type safety reasons