-
-
Notifications
You must be signed in to change notification settings - Fork 31
Open
Labels
Description
Is your feature request related to a problem? Please describe.
My problem is the command property must be a function. Because of that, I must use this in it for the object to be testable.
Describe the solution you'd like
I suggest introducing a new prop executeCommand: (command: Command) => void which will take the command object and execute it. That way the command object can contain only data and no this need to be used.
Additional context
An example would be:
Without executeCommand:
function go() {
history.go(this.link);
}
const props = {
options: [
{
name: "Go to example",
link: "http://example.com",
command: go
},
],
};With executeCommand:
const props = {
options: [
{
name: "Go to example",
link: "http://example.com",
},
],
executeCommand: (command) => {
history.go(command.link)
}
};danopia