-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# Custom contexts | ||
|
||
VSCode's [when clause contexts](https://code.visualstudio.com/api/references/when-clause-contexts) can be used to selectively enable or disable extension commands and UI elements, such as menus and views. <ReactiveVscode /> provides `reactive::useVscodeContext` to define custom contexts in a reactive way. | ||
|
||
```ts | ||
import { computed, defineExtension, ref, useVscodeContext } from 'reactive-vscode' | ||
|
||
export = defineExtension(() => { | ||
const contextA = useVscodeContext('demo.fromValue', true) | ||
// ^? | ||
|
||
const contextB = useVscodeContext('demo.fromRef', contextA) | ||
|
||
const contextC = useVscodeContext('demo.fromGetter', () => !contextA.value) | ||
// ^? | ||
}) | ||
``` | ||
|
||
For more information about when clause contexts, please refer to the [official documentation](https://code.visualstudio.com/api/references/when-clause-contexts). |