Skip to content

Commit 0b35bc4

Browse files
Openblocks-docsgitbook-bot
Openblocks-docs
authored andcommitted
GITBOOK-135: Add doc: Data responder
1 parent 7d83174 commit 0b35bc4

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed
69.6 KB
Loading
72 KB
Loading
106 KB
Loading

‎docs/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
* [JavaScript query](build-apps/write-javascript/javascript-query.md)
4848
* [Transformers](build-apps/write-javascript/transformers.md)
4949
* [Temporary state](build-apps/write-javascript/temporary-state.md)
50+
* [Data responder](build-apps/write-javascript/data-responder.md)
5051
* [Built-in JavaScript functions](build-apps/write-javascript/built-in-javascript-functions.md)
5152
* [Use third-party libraries](build-apps/use-third-party-libraries.md)
5253
* [Component guides](build-apps/component-guides/README.md)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Data responder
2+
3+
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".
4+
5+
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.
6+
7+
{% hint style="info" %}
8+
Events for data responders are more general than the events that listen to data changes such as content change, row select change, etc.
9+
{% endhint %}
10+
11+
## Listen to data changes
12+
13+
In query editor, click **+ New**, and then select **Data responder** to create a new data responder.
14+
15+
<figure><img src="../../.gitbook/assets/data-responder-1.png" alt=""><figcaption></figcaption></figure>
16+
17+
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.
18+
19+
<figure><img src="../../.gitbook/assets/data-responder-2.png" alt=""><figcaption></figcaption></figure>
20+
21+
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.
22+
23+
<figure><img src="../../.gitbook/assets/data-responder-3.png" alt=""><figcaption></figcaption></figure>
24+
25+
## Respond actions
26+
27+
For detailed information, go to [Event handlers](../event-handlers.md) > [Actions](../event-handlers.md#actions).

0 commit comments

Comments
 (0)