@ea-lab/reactive-json-docs 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/public/rjbuild/docs/advanced-concepts/data-mapping.md +76 -0
- package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +140 -0
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +373 -0
- package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +309 -0
- package/public/rjbuild/docs/advanced-concepts/index.md +10 -0
- package/public/rjbuild/docs/advanced-concepts/index.yaml +16 -0
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development-guide-llm.md +2 -0
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development.md +1 -1
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/component-development.yaml +1 -1
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/plugin-system.md +2 -0
- package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/plugin-system.yaml +2 -0
- package/public/rjbuild/docs/core/action/Hide.md +1 -1
- package/public/rjbuild/docs/core/action/Hide.yaml +10 -10
- package/public/rjbuild/docs/core/action/ReactOnEvent.md +12 -12
- package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +61 -101
- package/public/rjbuild/docs/core/action/Redirect.md +10 -2
- package/public/rjbuild/docs/core/action/Redirect.yaml +18 -51
- package/public/rjbuild/docs/core/action/VisuallyHide.yaml +10 -12
- package/public/rjbuild/docs/core/action/index.md +19 -204
- package/public/rjbuild/docs/core/action/index.yaml +19 -264
- package/public/rjbuild/docs/core/dataMapping/index.md +31 -0
- package/public/rjbuild/docs/core/dataMapping/index.yaml +24 -0
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.md +131 -0
- package/public/rjbuild/docs/core/dataMapping/simpleMapping.yaml +376 -0
- package/public/rjbuild/docs/core/element/form/DateField.md +1 -1
- package/public/rjbuild/docs/core/element/form/DateField.yaml +4 -4
- package/public/rjbuild/docs/core/element/form/SelectField.yaml +2 -2
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.md +4 -3
- package/public/rjbuild/docs/core/element/special/ReactiveJsonSubroot.yaml +114 -6
- package/public/rjbuild/docs/core/example/website.yaml +10 -10
- package/public/rjbuild/docs/core/reaction/index.md +17 -229
- package/public/rjbuild/docs/core/reaction/index.yaml +14 -242
- package/public/rjbuild/docs/core/reaction/setData.md +1 -1
- package/public/rjbuild/docs/core/reaction/setData.yaml +1 -1
- package/public/rjbuild/docs/docs-components/index.md +0 -2
- package/public/rjbuild/docs/docs-components/index.yaml +0 -2
- package/public/rjbuild/docs/getting-started/actions.md +294 -0
- package/public/rjbuild/docs/getting-started/actions.yaml +403 -0
- package/public/rjbuild/docs/{getting-started.md → getting-started/index.md} +30 -6
- package/public/rjbuild/docs/{getting-started.yaml → getting-started/index.yaml} +22 -6
- package/public/rjbuild/docs/getting-started/reactions.md +301 -0
- package/public/rjbuild/docs/getting-started/reactions.yaml +300 -0
- package/public/rjbuild/docs/getting-started/rjbuild-structure.md +358 -0
- package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +421 -0
- package/public/rjbuild/docs/{template.md → getting-started/template-contexts-data-binding.md} +16 -12
- package/public/rjbuild/docs/{template.yaml → getting-started/template-contexts-data-binding.yaml} +28 -14
- package/public/rjbuild/docs/install.yaml +682 -681
- /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.md +0 -0
- /package/public/rjbuild/docs/{core/reaction → advanced-concepts}/forward-update.yaml +0 -0
- /package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/index.md +0 -0
- /package/public/rjbuild/docs/{extend → advanced-concepts/plugins}/index.yaml +0 -0
|
@@ -8,13 +8,121 @@ renderView:
|
|
|
8
8
|
With the `sharedUpdates` feature, the component can also propagate data changes back to the parent, enabling seamless communication between parent and subroot when working with shared data references.
|
|
9
9
|
|
|
10
10
|
## Properties
|
|
11
|
-
- `rjOptions` (object, required): Options to pass to the subroot - accepts **all** `ReactiveJsonRoot` properties.
|
|
12
|
-
- Direct properties: `rjBuildUrl`, `dataOverride`, `headersForRjBuild`, `debugMode`, etc.
|
|
13
|
-
- For inline content: use `maybeRawAppRjBuild` containing `renderView`, `templates`, `data`.
|
|
14
|
-
- `sharedUpdates` (boolean, optional): Enable upstream data propagation to parent (default: false).
|
|
15
|
-
- `dataOverrideEvaluationDepth` (number, optional): Special evaluation depth for dataOverride property.
|
|
16
|
-
- Other properties are passed to the underlying `ActionDependant` wrapper.
|
|
17
11
|
|
|
12
|
+
- type: TabbedSerializer
|
|
13
|
+
yamlSerializedContent: |
|
|
14
|
+
# Complete rjOptions structure.
|
|
15
|
+
- type: ReactiveJsonSubroot
|
|
16
|
+
# Component-specific properties.
|
|
17
|
+
sharedUpdates: true
|
|
18
|
+
dataOverrideEvaluationDepth: 10
|
|
19
|
+
|
|
20
|
+
# Subroot configuration.
|
|
21
|
+
rjOptions:
|
|
22
|
+
# Loading from URL.
|
|
23
|
+
rjBuildUrl: "/path/to/rjbuild.yaml"
|
|
24
|
+
rjBuildFetchMethod: "GET" # or "POST".
|
|
25
|
+
headersForRjBuild:
|
|
26
|
+
Authorization: "Bearer token"
|
|
27
|
+
Content-Type: "application/json"
|
|
28
|
+
|
|
29
|
+
# OR inline definition.
|
|
30
|
+
maybeRawAppRjBuild:
|
|
31
|
+
renderView:
|
|
32
|
+
- type: div
|
|
33
|
+
content: "Subroot content."
|
|
34
|
+
templates:
|
|
35
|
+
myTemplate:
|
|
36
|
+
type: span
|
|
37
|
+
content: ~.value
|
|
38
|
+
data:
|
|
39
|
+
initialValue: "Hello World"
|
|
40
|
+
|
|
41
|
+
# Data replacement.
|
|
42
|
+
dataOverride: ~~.userData
|
|
43
|
+
|
|
44
|
+
# Debug mode.
|
|
45
|
+
debugMode: true
|
|
46
|
+
|
|
47
|
+
# Standard actions.
|
|
48
|
+
actions:
|
|
49
|
+
- what: hide
|
|
50
|
+
when: ~.condition
|
|
51
|
+
|
|
52
|
+
- type: DefinitionList
|
|
53
|
+
content:
|
|
54
|
+
- term:
|
|
55
|
+
code: rjOptions
|
|
56
|
+
after: " (object, required)"
|
|
57
|
+
details:
|
|
58
|
+
- type: Markdown
|
|
59
|
+
content: "Options to pass to the subroot - accepts **all** `ReactiveJsonRoot` properties including:"
|
|
60
|
+
|
|
61
|
+
- type: DefinitionList
|
|
62
|
+
content:
|
|
63
|
+
- term:
|
|
64
|
+
code: rjOptions.rjBuildUrl
|
|
65
|
+
details: "URL to load the RjBuild from."
|
|
66
|
+
|
|
67
|
+
- term:
|
|
68
|
+
code: rjOptions.rjBuildFetchMethod
|
|
69
|
+
details: "HTTP method (\"GET\" or \"POST\")."
|
|
70
|
+
|
|
71
|
+
- term:
|
|
72
|
+
code: rjOptions.headersForRjBuild
|
|
73
|
+
details: "Headers for the request."
|
|
74
|
+
|
|
75
|
+
- term:
|
|
76
|
+
code: rjOptions.dataOverride
|
|
77
|
+
details: "Override data for the loaded/defined RjBuild."
|
|
78
|
+
|
|
79
|
+
- term:
|
|
80
|
+
code: rjOptions.maybeRawAppRjBuild
|
|
81
|
+
details:
|
|
82
|
+
- type: Markdown
|
|
83
|
+
content: "Inline RjBuild content (string or object) containing:"
|
|
84
|
+
|
|
85
|
+
- type: DefinitionList
|
|
86
|
+
content:
|
|
87
|
+
- term:
|
|
88
|
+
code: rjOptions.maybeRawAppRjBuild.renderView
|
|
89
|
+
details: "View definition."
|
|
90
|
+
|
|
91
|
+
- term:
|
|
92
|
+
code: rjOptions.maybeRawAppRjBuild.templates
|
|
93
|
+
details: "Template definitions."
|
|
94
|
+
|
|
95
|
+
- term:
|
|
96
|
+
code: rjOptions.maybeRawAppRjBuild.data
|
|
97
|
+
details: "Initial data."
|
|
98
|
+
|
|
99
|
+
- term:
|
|
100
|
+
code: rjOptions.debugMode
|
|
101
|
+
details: "Enable debug mode and related wrapper components."
|
|
102
|
+
|
|
103
|
+
- term:
|
|
104
|
+
code: sharedUpdates
|
|
105
|
+
after: " (boolean, optional)"
|
|
106
|
+
details: "Enable upstream data propagation to parent (default: false)."
|
|
107
|
+
|
|
108
|
+
- term:
|
|
109
|
+
code: dataOverrideEvaluationDepth
|
|
110
|
+
after: " (number, optional)"
|
|
111
|
+
details: "Special evaluation depth for dataOverride property (default: 10)."
|
|
112
|
+
|
|
113
|
+
- type: Markdown
|
|
114
|
+
content: |
|
|
115
|
+
### Standard properties
|
|
116
|
+
|
|
117
|
+
- type: DefinitionList
|
|
118
|
+
content:
|
|
119
|
+
- term:
|
|
120
|
+
code: actions
|
|
121
|
+
after: " (array, optional)"
|
|
122
|
+
details: "Actions to attach to the subroot."
|
|
123
|
+
|
|
124
|
+
- type: Markdown
|
|
125
|
+
content: |
|
|
18
126
|
## Behavior
|
|
19
127
|
- Renders a new `ReactiveJsonRoot` with the provided options.
|
|
20
128
|
- The subroot is typically isolated from the parent for data, templates, and rendering¹.
|
|
@@ -1252,11 +1252,11 @@ renderView:
|
|
|
1252
1252
|
- what: hide
|
|
1253
1253
|
andConditions:
|
|
1254
1254
|
- when: ~.contact_form.nom
|
|
1255
|
-
|
|
1255
|
+
isNotEmpty:
|
|
1256
1256
|
- when: ~.contact_form.email
|
|
1257
|
-
|
|
1257
|
+
isNotEmpty:
|
|
1258
1258
|
- when: ~.contact_form.sujet
|
|
1259
|
-
|
|
1259
|
+
isNotEmpty:
|
|
1260
1260
|
content: "Complétez tous les champs"
|
|
1261
1261
|
|
|
1262
1262
|
# Bouton Suivant actif
|
|
@@ -1289,11 +1289,11 @@ renderView:
|
|
|
1289
1289
|
value: 2
|
|
1290
1290
|
andConditions:
|
|
1291
1291
|
- when: ~.contact_form.nom
|
|
1292
|
-
|
|
1292
|
+
isNotEmpty:
|
|
1293
1293
|
- when: ~.contact_form.email
|
|
1294
|
-
|
|
1294
|
+
isNotEmpty:
|
|
1295
1295
|
- when: ~.contact_form.sujet
|
|
1296
|
-
|
|
1296
|
+
isNotEmpty:
|
|
1297
1297
|
content: "Suivant →"
|
|
1298
1298
|
|
|
1299
1299
|
# Boutons de navigation - ÉTAPE 2
|
|
@@ -1345,7 +1345,7 @@ renderView:
|
|
|
1345
1345
|
actions:
|
|
1346
1346
|
- what: hide
|
|
1347
1347
|
when: ~.contact_form.message
|
|
1348
|
-
|
|
1348
|
+
isNotEmpty:
|
|
1349
1349
|
content: "Veuillez saisir votre message"
|
|
1350
1350
|
|
|
1351
1351
|
# Bouton Envoyer actif
|
|
@@ -1371,19 +1371,19 @@ renderView:
|
|
|
1371
1371
|
path: ~.show_contact_modal
|
|
1372
1372
|
value: false
|
|
1373
1373
|
when: ~.contact_form.message
|
|
1374
|
-
|
|
1374
|
+
isNotEmpty:
|
|
1375
1375
|
- what: setData
|
|
1376
1376
|
on: click
|
|
1377
1377
|
path: ~.message_sent
|
|
1378
1378
|
value: true
|
|
1379
1379
|
when: ~.contact_form.message
|
|
1380
|
-
|
|
1380
|
+
isNotEmpty:
|
|
1381
1381
|
- what: setData
|
|
1382
1382
|
on: click
|
|
1383
1383
|
path: ~.contact_form_step
|
|
1384
1384
|
value: 1
|
|
1385
1385
|
when: ~.contact_form.message
|
|
1386
|
-
|
|
1386
|
+
isNotEmpty:
|
|
1387
1387
|
content: "Envoyer la Missive"
|
|
1388
1388
|
|
|
1389
1389
|
templates:
|
|
@@ -1,236 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Reactions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> For an introduction to the reactions system and detailed examples, see [Getting Started: Reactions](../../getting-started/reactions.md).
|
|
4
4
|
|
|
5
|
-
Reactions
|
|
5
|
+
Reactions in Reactive-JSON allow you to respond to user events and perform operations like data updates, network requests, and browser interactions. They execute in response to user events to modify application state and trigger behaviors.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
```yaml
|
|
9
|
-
renderView:
|
|
10
|
-
- type: button
|
|
11
|
-
content: Click me
|
|
12
|
-
actions:
|
|
13
|
-
- what: setData # Reaction type
|
|
14
|
-
on: click # Event that triggers the reaction
|
|
15
|
-
path: ~.my_state # Where to store the data
|
|
16
|
-
value: "on" # Value to set
|
|
17
|
-
```
|
|
7
|
+
## Available Reaction Components
|
|
18
8
|
|
|
19
|
-
|
|
9
|
+
### Data Management
|
|
10
|
+
- **[setData](./setData.md)**: Sets data at the specified path
|
|
11
|
+
- **[addData](./addData.md)**: Adds new data to the specified path
|
|
12
|
+
- **[removeData](./removeData.md)**: Removes data from the specified path
|
|
13
|
+
- **[moveData](./moveData.md)**: Moves data from one path to another
|
|
20
14
|
|
|
21
|
-
###
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
- `removeData` : Removes data from the specified path
|
|
25
|
-
- `moveData` : Moves data from one path to another
|
|
15
|
+
### Network Operations
|
|
16
|
+
- **[fetchData](./fetchData.md)**: Fetches data from a URL using GET requests
|
|
17
|
+
- **[submitData](./submitData.md)**: Submits data to a server endpoint using POST/PUT/DELETE
|
|
26
18
|
|
|
27
|
-
###
|
|
28
|
-
-
|
|
29
|
-
-
|
|
19
|
+
### Browser Operations
|
|
20
|
+
- **[setClipboardData](./setClipboardData.md)**: Copies data to the clipboard
|
|
21
|
+
- **[redirectNow](./redirectNow.md)**: Performs an immediate redirect
|
|
22
|
+
- **[triggerEvent](./triggerEvent.md)**: Triggers a custom event
|
|
23
|
+
- **[postMessage](./postMessage.md)**: Sends a message to another window/frame
|
|
30
24
|
|
|
31
|
-
### 1.3 Browser Operations
|
|
32
|
-
- `setClipboardData` : Copies data to the clipboard
|
|
33
|
-
- `redirectNow` : Performs an immediate redirect
|
|
34
|
-
- `triggerEvent` : Triggers a custom event
|
|
35
|
-
- `postMessage` : Sends a message to another window/frame
|
|
36
|
-
|
|
37
|
-
## 2. Reaction Structure
|
|
38
|
-
Each reaction is defined by:
|
|
39
|
-
- `what` : The name of the reaction to execute
|
|
40
|
-
- `on` : The event that triggers the reaction
|
|
41
|
-
- Reaction-specific options (vary by reaction type)
|
|
42
|
-
- **Optional conditions** : Reactions support the same conditional system as actions
|
|
43
|
-
|
|
44
|
-
### 2.1 Conditional Reactions
|
|
45
|
-
Just like actions, reactions can be made conditional using various comparison operators:
|
|
46
|
-
|
|
47
|
-
- `when` + `is` / `isNot` : Value equality checks
|
|
48
|
-
- `when` + `isEmpty` : Empty value tests
|
|
49
|
-
- `when` + `contains` / `containsNot` : Content search
|
|
50
|
-
- `when` + `>`, `<`, `>=`, `<=` : Numeric/date comparisons
|
|
51
|
-
- `andConditions` / `orConditions` : Complex condition logic
|
|
52
|
-
|
|
53
|
-
For example:
|
|
54
|
-
```yaml
|
|
55
|
-
actions:
|
|
56
|
-
- what: setData # Reaction name
|
|
57
|
-
on: click # Triggering event
|
|
58
|
-
path: ~.user.profile # Reaction-specific option
|
|
59
|
-
value: ~.form_data # Reaction-specific option
|
|
60
|
-
when: ~.is_editing # Condition - only execute if editing
|
|
61
|
-
is: true # Condition value
|
|
62
|
-
- what: submitData # Reaction name
|
|
63
|
-
on: submit # Triggering event
|
|
64
|
-
url: "/api/endpoint" # Reaction-specific option
|
|
65
|
-
method: "POST" # Reaction-specific option
|
|
66
|
-
data: ~.form_data # Reaction-specific option
|
|
67
|
-
when: ~.form_data # Condition - only submit if form has data
|
|
68
|
-
isEmpty: "not" # Condition check
|
|
69
|
-
- what: setData # Multiple conditions example
|
|
70
|
-
on: click
|
|
71
|
-
path: ~.result
|
|
72
|
-
value: "success"
|
|
73
|
-
andConditions: # All conditions must be true
|
|
74
|
-
- when: ~.user.role
|
|
75
|
-
is: "admin"
|
|
76
|
-
- when: ~.feature_enabled
|
|
77
|
-
is: true
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
## 3. Event Types
|
|
81
|
-
The `on` property accepts standard browser events. These events are the same as those used in standard web development, and their availability depends on the HTML element type. For example, a `change` event will only work on form elements like `input`, `select`, or `textarea`, while a `click` event works on any element.
|
|
82
|
-
|
|
83
|
-
Common event types:
|
|
84
|
-
- `click` : Mouse click (works on any element)
|
|
85
|
-
- `change` : Form input change (works on form elements only)
|
|
86
|
-
- `submit` : Form submission (works on form elements only)
|
|
87
|
-
- `keydown` : Keyboard key press (works on elements that can receive focus)
|
|
88
|
-
- `keyup` : Keyboard key release (works on elements that can receive focus)
|
|
89
|
-
|
|
90
|
-
## 4. Event Control
|
|
91
|
-
The `stopPropagation` property can be used to control event bubbling and subsequent actions:
|
|
92
|
-
```yaml
|
|
93
|
-
actions:
|
|
94
|
-
- what: setData
|
|
95
|
-
on: click
|
|
96
|
-
path: ~.state
|
|
97
|
-
value: "on"
|
|
98
|
-
stopPropagation: true # Prevents event bubbling AND stops execution of subsequent actions
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
When `stopPropagation` is set to `true`, it:
|
|
102
|
-
1. Prevents the event from bubbling up to parent elements
|
|
103
|
-
2. Stops the execution of any subsequent actions defined for the same event
|
|
104
|
-
|
|
105
|
-
This is particularly useful when you want to ensure that only the first matching action is executed, even if multiple actions are defined for the same event.
|
|
106
|
-
|
|
107
|
-
## 5. Technical Details
|
|
108
|
-
- Reactions are triggered by events
|
|
109
|
-
- Multiple reactions can be defined for the same event
|
|
110
|
-
- Reactions are executed in order
|
|
111
|
-
- Reactions can be chained together
|
|
112
|
-
- **Reactions support all the same conditional operators as actions**: `when`, `is`, `isNot`, `isEmpty`, `contains`, `>`, `<`, `>=`, `<=`, `andConditions`, `orConditions`
|
|
113
|
-
- Conditional reactions only execute when their conditions evaluate to true
|
|
114
|
-
- The execution order of multiple reactions on the same event is guaranteed to match their order in the YAML
|
|
115
|
-
- If a reaction's conditions are not met, it is skipped and the next reaction is evaluated
|
|
116
|
-
|
|
117
|
-
## 6. Limitations
|
|
118
|
-
- Reactions cannot modify external state
|
|
119
|
-
- Network operations must be properly configured
|
|
120
|
-
- Browser operations require appropriate permissions
|
|
121
|
-
|
|
122
|
-
## 7. Complete Examples
|
|
123
|
-
|
|
124
|
-
### 7.1 Data Input and Submission
|
|
125
|
-
```yaml
|
|
126
|
-
renderView:
|
|
127
|
-
- type: TextField
|
|
128
|
-
label: "Username"
|
|
129
|
-
placeholder: "Enter your username"
|
|
130
|
-
dataLocation: ~.form_data.username
|
|
131
|
-
- type: TextField
|
|
132
|
-
label: "Email"
|
|
133
|
-
placeholder: "Enter your email"
|
|
134
|
-
inputType: "email"
|
|
135
|
-
dataLocation: ~.form_data.email
|
|
136
|
-
- type: button
|
|
137
|
-
content: Submit
|
|
138
|
-
actions:
|
|
139
|
-
- what: submitData
|
|
140
|
-
on: click
|
|
141
|
-
url: "/api/submit"
|
|
142
|
-
data:
|
|
143
|
-
username: ~.form_data.username
|
|
144
|
-
email: ~.form_data.email
|
|
145
|
-
when: ~.form_data.username
|
|
146
|
-
isEmpty: not
|
|
147
|
-
|
|
148
|
-
data:
|
|
149
|
-
form_data:
|
|
150
|
-
username: ""
|
|
151
|
-
email: ""
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
### 7.2 Conditional Reactions Example
|
|
155
|
-
```yaml
|
|
156
|
-
renderView:
|
|
157
|
-
- type: button
|
|
158
|
-
content: "Toggle State"
|
|
159
|
-
actions:
|
|
160
|
-
- what: setData
|
|
161
|
-
on: click
|
|
162
|
-
path: ~.button_state
|
|
163
|
-
value: "on"
|
|
164
|
-
when: ~.button_state
|
|
165
|
-
is: "off"
|
|
166
|
-
stopPropagation: true
|
|
167
|
-
- what: setData
|
|
168
|
-
on: click
|
|
169
|
-
path: ~.button_state
|
|
170
|
-
value: "off"
|
|
171
|
-
when: ~.button_state
|
|
172
|
-
is: "on"
|
|
173
|
-
stopPropagation: true
|
|
174
|
-
- type: div
|
|
175
|
-
content: ["Button state: ", ~.button_state]
|
|
176
|
-
- type: div
|
|
177
|
-
content: "Button has been clicked!"
|
|
178
|
-
actions:
|
|
179
|
-
- what: hide
|
|
180
|
-
when: ~.button_state
|
|
181
|
-
is: "off"
|
|
182
|
-
|
|
183
|
-
data:
|
|
184
|
-
button_state: "off"
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
### 7.3 Complex Conditional Logic
|
|
188
|
-
```yaml
|
|
189
|
-
renderView:
|
|
190
|
-
- type: TextField
|
|
191
|
-
label: "Enter a number:"
|
|
192
|
-
dataLocation: ~.user_input
|
|
193
|
-
inputType: "number"
|
|
194
|
-
- type: button
|
|
195
|
-
content: "Process Number"
|
|
196
|
-
actions:
|
|
197
|
-
- what: setData
|
|
198
|
-
on: click
|
|
199
|
-
path: ~.result
|
|
200
|
-
value: "Number is valid and positive!"
|
|
201
|
-
andConditions:
|
|
202
|
-
- when: ~.user_input
|
|
203
|
-
isEmpty: "not"
|
|
204
|
-
- when: ~.user_input
|
|
205
|
-
">": 0
|
|
206
|
-
- what: setData
|
|
207
|
-
on: click
|
|
208
|
-
path: ~.result
|
|
209
|
-
value: "Number must be positive!"
|
|
210
|
-
when: ~.user_input
|
|
211
|
-
"<=": 0
|
|
212
|
-
- what: setData
|
|
213
|
-
on: click
|
|
214
|
-
path: ~.result
|
|
215
|
-
value: "Please enter a number!"
|
|
216
|
-
when: ~.user_input
|
|
217
|
-
isEmpty: true
|
|
218
|
-
- type: div
|
|
219
|
-
content: ["Result: ", ~.result]
|
|
220
|
-
actions:
|
|
221
|
-
- what: hide
|
|
222
|
-
when: ~.result
|
|
223
|
-
isEmpty: true
|
|
224
|
-
|
|
225
|
-
data:
|
|
226
|
-
user_input: null
|
|
227
|
-
result: null
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
## Conclusion
|
|
231
|
-
|
|
232
|
-
You now have a good understanding of reactions in Reactive-JSON. We've seen how they allow you to respond to user events and perform various operations like data updates and network requests.
|
|
233
|
-
|
|
234
|
-
To create complete interactive interfaces, you should combine reactions with actions. Actions handle the conditional behavior of elements, while reactions handle user interactions and data updates.
|
|
235
|
-
|
|
236
|
-
For more information about actions and conditional behavior, check out the [Actions Documentation](../action/index.md).
|