You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment there is no way to pass command context which could be necessary for such a command like attachment to pass Promise to the command.
Current implementation: commandController.executeCommand('myCommandName');
1st Idea
The idea: commandController.executeCommand('myCommandName', commandContext);
To implement such functionality it is necessary
update the command type ICommand make it generic something like ICommand<CommandContext>
update CommandController so the instance could understand ICommand generic type
constcommandWithoutContext: ICommand={...};constcommandWithContext: ICommand<number>={...};const{ ref, commandController }=useTextAreaMarkdownEditor({commandMap: {commandName1: commandWithoutContext,commandName2: commandWithContext,},});commandController.executeCommand('commandName1');// No errorcommandController.executeCommand('commandName1',42);// Error: only 1 argument expectedcommandController.executeCommand('commandName2');// Error: only 2 arguments expectedcommandController.executeCommand('commandName2',42);// No error
2nd Idea
Current API can be changed this way:
classCommandWithoutContextextendsBaseCommand{...};classCommandWithContextextendsBaseCommand<number>{...};const{ ref,commands{
commandName1,
commandName2,}}=useTextAreaMarkdownEditor({commandMap: {commandName1: CommandWithoutContext,commandName2: CommandWithContext,},});commandName1();// No errorcommandName1(42);// Error: 0 arguments expectedcommandName2();// Error: 1 argument expectedcommandName2(42);// No error
Such changes require complex types inference logic wich I didn't implement at the moment.
If anyone has code examples of such type inference logic please share them here. Any idea will be highly appreciated.
The text was updated successfully, but these errors were encountered:
At the moment there is no way to pass command context which could be necessary for such a command like
attachment
to passPromise
to the command.Current implementation:
commandController.executeCommand('myCommandName');
1st Idea
The idea:
commandController.executeCommand('myCommandName', commandContext);
To implement such functionality it is necessary
ICommand
make it generic something likeICommand<CommandContext>
ICommand
generic type2nd Idea
Current API can be changed this way:
Such changes require complex types inference logic wich I didn't implement at the moment.
If anyone has code examples of such type inference logic please share them here. Any idea will be highly appreciated.
The text was updated successfully, but these errors were encountered: