Skip to content

Commit

Permalink
docs: add command behaviors to disambiguate situations in which comma…
Browse files Browse the repository at this point in the history
…nds may behave unexpectedly
  • Loading branch information
dannyrb committed Dec 9, 2019
1 parent cd1cbf0 commit fd7620c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions docs/latest/extensions/modules/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,28 @@ myCommandName: {
| `options` | object | (optional) Arguments to pass at the time of calling to the `commandFn` |
| `context` | string[] or string | (optional) Overrides the `defaultContext`. Let's us know if command is currently "available" to be run. |

## Command Behavior

**I have many similar commands. How can I share their `commandFn` and make it
reusable?**

This is where `storeContexts` and `options` come in. We use these in our
`setToolActive` command. `storeContexts` helps us identify our `activeViewport`,
and `options` allow us to pass in the name of a tool we would like to set as
active.

**If there are multiple valid commands for the application's active contexts**

- What happens: all commands are run
- When to use: A `clearData` command that cleans up state for multiple
extensions

**If no commands are valid for the application's active contexts**

- What happens: a warning is printed to the console
- When to use: a `hotkey` (like "invert") that doesn't make sense for the
current viewport (PDF or HTML)

## `CommandsManager`

The `CommandsManager` is a class defined in the `@ohif/core` project. A single
Expand Down

0 comments on commit fd7620c

Please sign in to comment.