@ea-lab/reactive-json-docs 0.4.0 → 0.6.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 +5 -2
- package/public/rjbuild/docs/advanced-concepts/index.md +1 -0
- package/public/rjbuild/docs/advanced-concepts/index.yaml +1 -0
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/component-development.yaml +1 -1
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +93 -0
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +141 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +267 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +244 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +108 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +135 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +135 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +185 -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 +24 -203
- package/public/rjbuild/docs/core/action/index.yaml +24 -263
- 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/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/index.md +30 -6
- package/public/rjbuild/docs/getting-started/index.yaml +20 -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 +10 -4
- package/public/rjbuild/docs/getting-started/rjbuild-structure.yaml +10 -4
- package/public/rjbuild/docs/getting-started/{template.md → template-contexts-data-binding.md} +16 -12
- package/public/rjbuild/docs/getting-started/{template.yaml → template-contexts-data-binding.yaml} +28 -14
- /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
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# Reactions System
|
|
5
|
+
|
|
6
|
+
Reactions are a fundamental part of Reactive-JSON's interactivity system. They allow you to respond to user events and perform operations like data updates, network requests, and browser interactions - all through JSON configuration. In the RjBuild, reactions are defined under the `actions` key, just like regular actions, but are distinguished by the presence of the `on` property.
|
|
7
|
+
|
|
8
|
+
Reactions execute in response to user events (click, change, etc.) to modify application state and trigger behaviors. They differ from [actions](./actions), which continuously adapt the UI based on the current data state; reactions are event-driven while actions are state-driven.
|
|
9
|
+
|
|
10
|
+
- type: Markdown
|
|
11
|
+
content: |
|
|
12
|
+
## Basic Syntax
|
|
13
|
+
|
|
14
|
+
Reactions are defined as part of the `actions` array on any element. Each reaction has the following core properties:
|
|
15
|
+
|
|
16
|
+
- type: DefinitionList
|
|
17
|
+
content:
|
|
18
|
+
- term:
|
|
19
|
+
code: what
|
|
20
|
+
details: "The name of the reaction to execute."
|
|
21
|
+
- term:
|
|
22
|
+
code: on
|
|
23
|
+
details: "The event that triggers the reaction."
|
|
24
|
+
- term:
|
|
25
|
+
code: when
|
|
26
|
+
after: " (optional)"
|
|
27
|
+
details:
|
|
28
|
+
type: Markdown
|
|
29
|
+
content: "Reactions also support optional conditions to control when the reaction should execute. See the [Actions conditional operators documentation](./actions#conditional-operators) for detailed information about available condition types."
|
|
30
|
+
|
|
31
|
+
- type: Markdown
|
|
32
|
+
content: |
|
|
33
|
+
Beyond these core properties, reactions include reaction-specific properties that vary depending on the reaction type. For example, a `setData` reaction requires `path` and `value` properties, while a `fetchData` reaction needs a `url` property and optional `method` configuration.
|
|
34
|
+
|
|
35
|
+
Reactions also support optional conditions using the same conditional system as actions. This allows you to create sophisticated event-driven behavior that only executes when specific data conditions are met.
|
|
36
|
+
|
|
37
|
+
- type: TabbedSerializer
|
|
38
|
+
yamlSerializedContent: |
|
|
39
|
+
renderView:
|
|
40
|
+
- type: button
|
|
41
|
+
content: "Save Text"
|
|
42
|
+
actions:
|
|
43
|
+
- what: setData # Reaction type
|
|
44
|
+
on: click # Triggering event
|
|
45
|
+
path: ~.saved_text # Reaction-specific property
|
|
46
|
+
value: ~.user_input # Reaction-specific property
|
|
47
|
+
when: ~.user_input # Optional condition
|
|
48
|
+
isNotEmpty: # Condition value
|
|
49
|
+
|
|
50
|
+
- type: RjBuildDescriber
|
|
51
|
+
title: "Basic Reaction Demonstration"
|
|
52
|
+
description:
|
|
53
|
+
- type: Markdown
|
|
54
|
+
content: |
|
|
55
|
+
This example demonstrates how to set data when a button is clicked.
|
|
56
|
+
|
|
57
|
+
On the *Save Text* button, we define a `setData` reaction that will set the text field value
|
|
58
|
+
in the `saved_text` data location when the button is clicked, but only if the text field is not empty.
|
|
59
|
+
|
|
60
|
+
toDescribe:
|
|
61
|
+
renderView:
|
|
62
|
+
- type: TextField
|
|
63
|
+
label: "Enter some text:"
|
|
64
|
+
dataLocation: ~.user_input
|
|
65
|
+
placeholder: "Type something..."
|
|
66
|
+
|
|
67
|
+
- type: button
|
|
68
|
+
content: "Save Text"
|
|
69
|
+
actions:
|
|
70
|
+
- what: setData # Reaction type
|
|
71
|
+
on: click # Triggering event
|
|
72
|
+
path: ~.saved_text # Reaction-specific property
|
|
73
|
+
value: ~.user_input # Reaction-specific property
|
|
74
|
+
when: ~.user_input # Optional condition
|
|
75
|
+
isNotEmpty: # Condition value
|
|
76
|
+
|
|
77
|
+
- type: div
|
|
78
|
+
content: ["Saved text: ", ~.saved_text]
|
|
79
|
+
actions:
|
|
80
|
+
- what: hide # Action (no 'on' property)
|
|
81
|
+
when: ~.saved_text # Condition
|
|
82
|
+
isEmpty:
|
|
83
|
+
|
|
84
|
+
data:
|
|
85
|
+
user_input: ""
|
|
86
|
+
saved_text: ""
|
|
87
|
+
|
|
88
|
+
- type: Markdown
|
|
89
|
+
content: |
|
|
90
|
+
## Reaction Types
|
|
91
|
+
|
|
92
|
+
Reactive-JSON provides several built-in reactions:
|
|
93
|
+
|
|
94
|
+
### Data Management
|
|
95
|
+
- **[setData](../core/reaction/setData)**: Sets data at the specified path.
|
|
96
|
+
- **[addData](../core/reaction/addData)**: Adds new data to the specified path.
|
|
97
|
+
- **[removeData](../core/reaction/removeData)**: Removes data from the specified path.
|
|
98
|
+
- **[moveData](../core/reaction/moveData)**: Moves data from one path to another.
|
|
99
|
+
|
|
100
|
+
### Network Operations
|
|
101
|
+
- **[fetchData](../core/reaction/fetchData)**: Fetches data from a URL using GET requests.
|
|
102
|
+
- **[submitData](../core/reaction/submitData)**: Submits data to a server endpoint using POST/PUT/DELETE.
|
|
103
|
+
|
|
104
|
+
### Browser Operations
|
|
105
|
+
- **[setClipboardData](../core/reaction/setClipboardData)**: Copies data to the clipboard.
|
|
106
|
+
- **[redirectNow](../core/reaction/redirectNow)**: Performs an immediate redirect.
|
|
107
|
+
- **[triggerEvent](../core/reaction/triggerEvent)**: Triggers a custom event.
|
|
108
|
+
- **[postMessage](../core/reaction/postMessage)**: Sends a message to another window/frame.
|
|
109
|
+
|
|
110
|
+
For detailed documentation of each reaction, including properties and examples, see their respective documentation pages.
|
|
111
|
+
|
|
112
|
+
- type: RjBuildDescriber
|
|
113
|
+
title: "Event Types"
|
|
114
|
+
description:
|
|
115
|
+
- type: Markdown
|
|
116
|
+
content: |
|
|
117
|
+
This example demonstrates the different event types supported by reactions.
|
|
118
|
+
|
|
119
|
+
Try interacting with the text field below to see which events are triggered:
|
|
120
|
+
- Type text to trigger `change` events
|
|
121
|
+
- Click on the field to trigger `click` events
|
|
122
|
+
- Hover over the field to trigger `mouseOver` events
|
|
123
|
+
|
|
124
|
+
toDescribe:
|
|
125
|
+
renderView:
|
|
126
|
+
- type: div
|
|
127
|
+
content: ["Last event type: ", ~.last_event_type]
|
|
128
|
+
attributes:
|
|
129
|
+
style:
|
|
130
|
+
padding: "10px"
|
|
131
|
+
border: "1px solid var(--bs-border-color, #dee2e6)"
|
|
132
|
+
borderRadius: "4px"
|
|
133
|
+
marginBottom: "10px"
|
|
134
|
+
fontWeight: "bold"
|
|
135
|
+
|
|
136
|
+
- type: TextField
|
|
137
|
+
label: "Interactive text field:"
|
|
138
|
+
dataLocation: ~.user_input
|
|
139
|
+
placeholder: "Click, type, or hover..."
|
|
140
|
+
actions:
|
|
141
|
+
- what: setData
|
|
142
|
+
on: click
|
|
143
|
+
path: ~.last_event_type
|
|
144
|
+
value: "click"
|
|
145
|
+
- what: setData
|
|
146
|
+
on: change
|
|
147
|
+
path: ~.last_event_type
|
|
148
|
+
value: "change"
|
|
149
|
+
- what: setData
|
|
150
|
+
on: mouseOver
|
|
151
|
+
path: ~.last_event_type
|
|
152
|
+
value: "mouseOver"
|
|
153
|
+
|
|
154
|
+
data:
|
|
155
|
+
last_event_type: "none"
|
|
156
|
+
user_input: ""
|
|
157
|
+
|
|
158
|
+
- type: Markdown
|
|
159
|
+
content: |
|
|
160
|
+
Common event types:
|
|
161
|
+
- `click`: Mouse click (works on any element).
|
|
162
|
+
- `change`: Form input change (works on form elements only).
|
|
163
|
+
- `mouseOver`: Mouse hover (works on any element).
|
|
164
|
+
- `submit`: Form submission (works on form elements only).
|
|
165
|
+
- `keyDown`/`keyUp`: Keyboard events (works on focusable elements).
|
|
166
|
+
|
|
167
|
+
> **Note**: Event names must respect standard React/DOM event naming conventions (camelCase).
|
|
168
|
+
|
|
169
|
+
- type: RjBuildDescriber
|
|
170
|
+
title: "Data Management Example"
|
|
171
|
+
description:
|
|
172
|
+
- type: Markdown
|
|
173
|
+
content: |
|
|
174
|
+
This example demonstrates the core data management reactions: setData, addData, and removeData.
|
|
175
|
+
|
|
176
|
+
toDescribe:
|
|
177
|
+
renderView:
|
|
178
|
+
- type: TextField
|
|
179
|
+
label: "Add item:"
|
|
180
|
+
dataLocation: ~.new_item
|
|
181
|
+
placeholder: "Enter item name"
|
|
182
|
+
|
|
183
|
+
- type: button
|
|
184
|
+
content: "Add Item"
|
|
185
|
+
actions:
|
|
186
|
+
- what: addData
|
|
187
|
+
on: click
|
|
188
|
+
path: ~.items
|
|
189
|
+
value:
|
|
190
|
+
name: ~.new_item
|
|
191
|
+
when: ~.new_item
|
|
192
|
+
isNotEmpty:
|
|
193
|
+
- what: setData
|
|
194
|
+
on: click
|
|
195
|
+
path: ~.new_item
|
|
196
|
+
value: ""
|
|
197
|
+
when: ~.new_item
|
|
198
|
+
isNotEmpty:
|
|
199
|
+
|
|
200
|
+
- type: div
|
|
201
|
+
content: "Items:"
|
|
202
|
+
attributes:
|
|
203
|
+
style:
|
|
204
|
+
fontWeight: "bold"
|
|
205
|
+
margin: "10px 0 5px 0"
|
|
206
|
+
|
|
207
|
+
- type: Switch
|
|
208
|
+
content: ~.items
|
|
209
|
+
singleOption:
|
|
210
|
+
load: itemTemplate
|
|
211
|
+
|
|
212
|
+
templates:
|
|
213
|
+
itemTemplate:
|
|
214
|
+
type: div
|
|
215
|
+
content:
|
|
216
|
+
- "• "
|
|
217
|
+
- ~.name
|
|
218
|
+
- type: button
|
|
219
|
+
content: " [Remove]"
|
|
220
|
+
attributes:
|
|
221
|
+
style:
|
|
222
|
+
marginLeft: "10px"
|
|
223
|
+
background: "red"
|
|
224
|
+
color: "white"
|
|
225
|
+
border: "none"
|
|
226
|
+
padding: "2px 8px"
|
|
227
|
+
fontSize: "12px"
|
|
228
|
+
actions:
|
|
229
|
+
- what: removeData
|
|
230
|
+
on: click
|
|
231
|
+
target: currentTemplateData
|
|
232
|
+
parentLevel: 0
|
|
233
|
+
|
|
234
|
+
data:
|
|
235
|
+
new_item: ""
|
|
236
|
+
items:
|
|
237
|
+
- name: "Sample item 1"
|
|
238
|
+
- name: "Sample item 2"
|
|
239
|
+
|
|
240
|
+
- type: Markdown
|
|
241
|
+
content: |
|
|
242
|
+
## Advanced Features
|
|
243
|
+
|
|
244
|
+
### Conditional Logic
|
|
245
|
+
Reactions support the same conditional operators as actions:
|
|
246
|
+
- `when` + `is`/`isNot`: Value equality checks.
|
|
247
|
+
- `when` + `isEmpty`: Empty value tests.
|
|
248
|
+
- `when` + `contains`/`containsNot`: Content search.
|
|
249
|
+
- `when` + `>`, `<`, `>=`, `<=`: Numeric/date comparisons.
|
|
250
|
+
- `andConditions`/`orConditions`: Complex condition logic.
|
|
251
|
+
|
|
252
|
+
### Event Control
|
|
253
|
+
Use `stopPropagation: true` to:
|
|
254
|
+
1. Prevent event bubbling to parent elements.
|
|
255
|
+
2. Stop execution of subsequent actions for the same event.
|
|
256
|
+
|
|
257
|
+
### Execution Order
|
|
258
|
+
- Multiple reactions on the same event execute in the order they are defined.
|
|
259
|
+
- Reactions with unmet conditions are skipped.
|
|
260
|
+
- Actions (without `on` property) are evaluated separately from reactions.
|
|
261
|
+
|
|
262
|
+
- type: Markdown
|
|
263
|
+
content: |
|
|
264
|
+
## Technical Details
|
|
265
|
+
|
|
266
|
+
- Reactions are triggered by DOM events.
|
|
267
|
+
- Multiple reactions can be defined for the same event.
|
|
268
|
+
- Reactions are executed in the order they appear in the YAML.
|
|
269
|
+
- Reactions can be chained together by modifying data that other reactions depend on.
|
|
270
|
+
- Conditional reactions only execute when their conditions evaluate to true.
|
|
271
|
+
- The `stopPropagation` property affects both event bubbling and subsequent action execution.
|
|
272
|
+
|
|
273
|
+
## Limitations
|
|
274
|
+
|
|
275
|
+
- Event availability depends on the HTML element type (e.g., `change` only works on form elements).
|
|
276
|
+
- Network operations require proper CORS configuration.
|
|
277
|
+
- Browser operations require appropriate permissions.
|
|
278
|
+
- No built-in error handling beyond console logging for network operations.
|
|
279
|
+
- Only one network request (fetch/submit) can be active at a time.
|
|
280
|
+
- URLs in network operations must be static strings (dynamic URLs not supported).
|
|
281
|
+
|
|
282
|
+
## Best Practices
|
|
283
|
+
|
|
284
|
+
1. **Use descriptive conditions**: Make your conditional logic clear and readable.
|
|
285
|
+
2. **Handle empty states**: Always consider what happens when data is empty or undefined.
|
|
286
|
+
3. **Order matters**: Place more specific conditions before general ones.
|
|
287
|
+
4. **Use stopPropagation wisely**: Only use it when you specifically need to prevent event bubbling or stop action execution.
|
|
288
|
+
5. **Test network operations**: Ensure your API endpoints return the expected format.
|
|
289
|
+
6. **Provide user feedback**: Use visual indicators during loading states.
|
|
290
|
+
|
|
291
|
+
## Next Steps
|
|
292
|
+
|
|
293
|
+
Congratulations! You've mastered the fundamentals of Reactive-JSON. You now understand how to structure RjBuilds, use templates, and create interactive applications with actions and reactions.
|
|
294
|
+
|
|
295
|
+
Ready to take your skills further? Explore the **[Advanced Concepts](../advanced-concepts/index)** to learn about data mapping, custom plugins, and performance optimization techniques.
|
|
296
|
+
|
|
297
|
+
## Related Documentation
|
|
298
|
+
|
|
299
|
+
- **[Actions System](./actions)**: Review state-driven UI adaptation.
|
|
300
|
+
- **[Template System](./template-contexts-data-binding)**: Revisit data binding patterns.
|
|
@@ -157,7 +157,7 @@ data:
|
|
|
157
157
|
isLoggedIn: true
|
|
158
158
|
```
|
|
159
159
|
|
|
160
|
-
> You can get more information about data access in the [template system documentation](./template.md).
|
|
160
|
+
> You can get more information about data access in the [template system documentation](./template-contexts-data-binding.md).
|
|
161
161
|
|
|
162
162
|
## Section `templates` (Optional)
|
|
163
163
|
|
|
@@ -347,6 +347,12 @@ additionalDataSource:
|
|
|
347
347
|
3. **Optimized templates**: Avoid overly complex templates
|
|
348
348
|
|
|
349
349
|
### Maintainability
|
|
350
|
-
1. **Consistent naming**: Use clear conventions for templates and data
|
|
351
|
-
2. **Documentation**: Comment complex sections
|
|
352
|
-
3. **Validation**: Verify the structure of your external data
|
|
350
|
+
1. **Consistent naming**: Use clear conventions for templates and data.
|
|
351
|
+
2. **Documentation**: Comment complex sections.
|
|
352
|
+
3. **Validation**: Verify the structure of your external data.
|
|
353
|
+
|
|
354
|
+
## Next Steps
|
|
355
|
+
|
|
356
|
+
Now that you understand the structure of RjBuilds, learn about the **[Template System](./template-contexts-data-binding.md)** to master data binding and create reusable components.
|
|
357
|
+
|
|
358
|
+
The template system is crucial for building maintainable and dynamic applications with Reactive-JSON.
|
|
@@ -183,7 +183,7 @@ renderView:
|
|
|
183
183
|
|
|
184
184
|
- type: Markdown
|
|
185
185
|
content: |
|
|
186
|
-
> You can get more information about data access in the [template system documentation](/docs/getting-started/template).
|
|
186
|
+
> You can get more information about data access in the [template system documentation](/docs/getting-started/template-contexts-data-binding).
|
|
187
187
|
|
|
188
188
|
## Section `templates` (Optional)
|
|
189
189
|
|
|
@@ -406,9 +406,15 @@ renderView:
|
|
|
406
406
|
3. **Optimized templates**: Avoid overly complex templates
|
|
407
407
|
|
|
408
408
|
### Maintainability
|
|
409
|
-
1. **Consistent naming**: Use clear conventions for templates and data
|
|
410
|
-
2. **Documentation**: Comment complex sections
|
|
411
|
-
3. **Validation**: Verify the structure of your external data
|
|
409
|
+
1. **Consistent naming**: Use clear conventions for templates and data.
|
|
410
|
+
2. **Documentation**: Comment complex sections.
|
|
411
|
+
3. **Validation**: Verify the structure of your external data.
|
|
412
|
+
|
|
413
|
+
## Next Steps
|
|
414
|
+
|
|
415
|
+
Now that you understand the structure of RjBuilds, learn about the **[Template System](./template-contexts-data-binding)** to master data binding and create reusable components.
|
|
416
|
+
|
|
417
|
+
The template system is crucial for building maintainable and dynamic applications with Reactive-JSON.
|
|
412
418
|
|
|
413
419
|
templates:
|
|
414
420
|
|
package/public/rjbuild/docs/getting-started/{template.md → template-contexts-data-binding.md}
RENAMED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
# Template and
|
|
2
|
-
|
|
3
|
-
## Introduction
|
|
1
|
+
# Template, Contexts, and Data Binding
|
|
4
2
|
|
|
5
3
|
The template system in reactive-json efficiently manages data contexts and their access. Understanding how templates "containerize" data is essential for properly using components, actions, and reactions.
|
|
6
4
|
|
|
@@ -110,10 +108,10 @@ data:
|
|
|
110
108
|
title: "User List"
|
|
111
109
|
config:
|
|
112
110
|
theme: "light"
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
111
|
+
level1:
|
|
112
|
+
items:
|
|
113
|
+
- name: "Item 1"
|
|
114
|
+
# userList template instances run here at: data.config.userSection.config.level1.items
|
|
117
115
|
|
|
118
116
|
templates:
|
|
119
117
|
userList:
|
|
@@ -130,7 +128,7 @@ templates:
|
|
|
130
128
|
|
|
131
129
|
renderView:
|
|
132
130
|
- type: Switch
|
|
133
|
-
content: ~~.config.userSection.level1.items
|
|
131
|
+
content: ~~.config.userSection.config.level1.items
|
|
134
132
|
singleOption:
|
|
135
133
|
load: userList
|
|
136
134
|
```
|
|
@@ -183,7 +181,13 @@ data:
|
|
|
183
181
|
|
|
184
182
|
## Best Practices
|
|
185
183
|
|
|
186
|
-
1. **Context Coherence**: Ensure components that need to share data are in the same context
|
|
187
|
-
2. **Global Access**: Use `~~.` for data that needs to be shared between different templates
|
|
188
|
-
3. **Hierarchical Navigation**: Use `~>key` to find nearest occurrence or `~~>key` to find global setting
|
|
189
|
-
4. **Local vs Global**: `~>` prioritizes local overrides, `~~>` prioritizes global settings
|
|
184
|
+
1. **Context Coherence**: Ensure components that need to share data are in the same context.
|
|
185
|
+
2. **Global Access**: Use `~~.` for data that needs to be shared between different templates.
|
|
186
|
+
3. **Hierarchical Navigation**: Use `~>key` to find nearest occurrence or `~~>key` to find global setting.
|
|
187
|
+
4. **Local vs Global**: `~>` prioritizes local overrides, `~~>` prioritizes global settings.
|
|
188
|
+
|
|
189
|
+
## Next Steps
|
|
190
|
+
|
|
191
|
+
Now that you understand the template system and data binding, learn about **[Actions](./actions.md)** to make your interfaces interactive and responsive to data changes.
|
|
192
|
+
|
|
193
|
+
Actions will allow you to hide, show, and manipulate elements based on the current application state.
|
package/public/rjbuild/docs/getting-started/{template.yaml → template-contexts-data-binding.yaml}
RENAMED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
renderView:
|
|
2
2
|
- type: Markdown
|
|
3
3
|
content: |
|
|
4
|
-
# Template and
|
|
5
|
-
|
|
6
|
-
## Introduction
|
|
4
|
+
# Template, Contexts, and Data Binding
|
|
7
5
|
|
|
8
6
|
The template system in reactive-json efficiently manages data contexts and their access. Understanding how templates "containerize" data is essential for properly using components, actions, and reactions.
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
## Context Notations
|
|
9
|
+
|
|
12
10
|
There are four main notations for accessing data:
|
|
13
11
|
|
|
14
12
|
- `~.` : Local context (relative to current template)
|
|
@@ -19,7 +17,9 @@ renderView:
|
|
|
19
17
|
Each notation is explained with examples below.
|
|
20
18
|
|
|
21
19
|
- type: RjBuildDescriber
|
|
22
|
-
title:
|
|
20
|
+
title:
|
|
21
|
+
type: Markdown
|
|
22
|
+
content: "Local Context: `~.`"
|
|
23
23
|
description:
|
|
24
24
|
- type: Markdown
|
|
25
25
|
content: |
|
|
@@ -34,7 +34,9 @@ renderView:
|
|
|
34
34
|
username: "John"
|
|
35
35
|
|
|
36
36
|
- type: RjBuildDescriber
|
|
37
|
-
title:
|
|
37
|
+
title:
|
|
38
|
+
type: Markdown
|
|
39
|
+
content: "Global Context: `~~.`"
|
|
38
40
|
description:
|
|
39
41
|
- type: Markdown
|
|
40
42
|
content: |
|
|
@@ -61,7 +63,9 @@ renderView:
|
|
|
61
63
|
isAdmin: true
|
|
62
64
|
|
|
63
65
|
- type: RjBuildDescriber
|
|
64
|
-
title:
|
|
66
|
+
title:
|
|
67
|
+
type: Markdown
|
|
68
|
+
content: "Nearest Key: `~>key`"
|
|
65
69
|
description:
|
|
66
70
|
- type: Markdown
|
|
67
71
|
content: |
|
|
@@ -89,7 +93,9 @@ renderView:
|
|
|
89
93
|
- name: "Item 1" # themeDisplay template runs here
|
|
90
94
|
|
|
91
95
|
- type: RjBuildDescriber
|
|
92
|
-
title:
|
|
96
|
+
title:
|
|
97
|
+
type: Markdown
|
|
98
|
+
content: "Top-level Key: `~~>key`"
|
|
93
99
|
description:
|
|
94
100
|
- type: Markdown
|
|
95
101
|
content: |
|
|
@@ -193,10 +199,10 @@ renderView:
|
|
|
193
199
|
title: "User List"
|
|
194
200
|
config:
|
|
195
201
|
theme: "light"
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
202
|
+
level1:
|
|
203
|
+
items:
|
|
204
|
+
- name: "Item 1"
|
|
205
|
+
# userList template instances run here at: data.config.userSection.config.level1.items
|
|
200
206
|
|
|
201
207
|
templates:
|
|
202
208
|
userList:
|
|
@@ -213,10 +219,18 @@ renderView:
|
|
|
213
219
|
|
|
214
220
|
renderView:
|
|
215
221
|
- type: Switch
|
|
216
|
-
content: ~~.config.userSection.level1.items
|
|
222
|
+
content: ~~.config.userSection.config.level1.items
|
|
217
223
|
singleOption:
|
|
218
224
|
load: userList
|
|
219
225
|
|
|
226
|
+
- type: Markdown
|
|
227
|
+
content: |
|
|
228
|
+
## Next Steps
|
|
229
|
+
|
|
230
|
+
Now that you understand the template system and data binding, learn about **[Actions](./actions)** to make your interfaces interactive and responsive to data changes.
|
|
231
|
+
|
|
232
|
+
Actions will allow you to hide, show, and manipulate elements based on the current application state.
|
|
233
|
+
|
|
220
234
|
templates:
|
|
221
235
|
|
|
222
236
|
data: {}
|
|
File without changes
|
|
File without changes
|