Skip to content

Commit

Permalink
Document context parameter of interactive UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ziad-saab committed Sep 24, 2024
1 parent a13b2a5 commit 9cb2059
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions snaps/features/custom-ui/interactive-ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ If you need to [update the interface](#update-an-interactive-interface) or
[get its state](#get-an-interactive-interfaces-state) at a future time, you should store its ID in
the Snap's storage.

### Optionally add context to an interface

You can optionally add context to an interface by passing a `context` object to the
[`snap_createInterface`](../../reference/snaps-api.md#snap_createinterface) method.
This object is optional and can contain any data you want to pass to the interface.
This context will be passed to [`onUserInput`](../../reference/entry-points.md#onuserinput) when the user interacts with the interface.

## Update an interactive interface

To update an interactive interface that is still active, use the
Expand Down
1 change: 1 addition & 0 deletions snaps/reference/entry-points.md
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,7 @@ To respond to [interactive UI](../features/custom-ui/interactive-ui.md) events,
- `name` - The name of the component that fired the event.
Optional when the event type is `ButtonClickEvent`.
- `value` - When the event type is `FormSubmitEvent`, the values in the form as an object.
- `context` - The context object passed to the interface when calling [`snap_createInterface`](./snaps-api.md#snap_createinterface), or `null`.

#### Example

Expand Down
1 change: 1 addition & 0 deletions snaps/reference/snaps-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -860,6 +860,7 @@ Creates an interactive interface for use in [interactive UI](../features/custom-
An object containing:

- `ui` - The [custom UI](../features/custom-ui/index.md) to create.
- `context` (optional) - A custom context object that will be passed to [`onUserInput`](./entry-points.md#onuserinput) when the user interacts with the interface.

#### Returns

Expand Down

0 comments on commit 9cb2059

Please sign in to comment.