Skip to content

Commit

Permalink
GITBOOK-135: Add doc: Data responder
Browse files Browse the repository at this point in the history
  • Loading branch information
Openblocks-docs authored and gitbook-bot committed Mar 28, 2023
1 parent 7d83174 commit 0b35bc4
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 0 deletions.
Binary file added docs/.gitbook/assets/data-responder-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/data-responder-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/.gitbook/assets/data-responder-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions docs/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
* [JavaScript query](build-apps/write-javascript/javascript-query.md)
* [Transformers](build-apps/write-javascript/transformers.md)
* [Temporary state](build-apps/write-javascript/temporary-state.md)
* [Data responder](build-apps/write-javascript/data-responder.md)
* [Built-in JavaScript functions](build-apps/write-javascript/built-in-javascript-functions.md)
* [Use third-party libraries](build-apps/use-third-party-libraries.md)
* [Component guides](build-apps/component-guides/README.md)
Expand Down
27 changes: 27 additions & 0 deletions docs/build-apps/write-javascript/data-responder.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Data responder

When building an app, you can set events for the components in order to listen to the changes of certain data. For example, for a **Table** component, the built-in events for the change of the `selectedRow` property include "Row select change", "Filter change", "Sort change", and "Page change".

However, there lacks similar events for some data changes, such as the changes of temporary states, transformers, or query results. Data responders are designed for these cases and allow you to listen and respond to any data change.

{% hint style="info" %}
Events for data responders are more general than the events that listen to data changes such as content change, row select change, etc.
{% endhint %}

## Listen to data changes

In query editor, click **+ New**, and then select **Data responder** to create a new data responder.

<figure><img src="../../.gitbook/assets/data-responder-1.png" alt=""><figcaption></figcaption></figure>

You can set the data that data responder listens to. It supports all kinds of data formats, including number, string, array, and JS object. In the following example, any value change in the **Text** component triggers a global notification.

<figure><img src="../../.gitbook/assets/data-responder-2.png" alt=""><figcaption></figcaption></figure>

If the data is in array or JS object format, then data change from any sub-element will trigger the configured event. For example, the data of `dataResponder2` is a JS object, which listens to two **Input** components in the app. Data change of any component triggers the same global notification.

<figure><img src="../../.gitbook/assets/data-responder-3.png" alt=""><figcaption></figcaption></figure>

## Respond actions

For detailed information, go to [Event handlers](../event-handlers.md) > [Actions](../event-handlers.md#actions).

0 comments on commit 0b35bc4

Please sign in to comment.