@ea-lab/reactive-json-docs 1.0.0-alpha.0 → 1.1.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/attribute-transformers.md +168 -0
- package/public/rjbuild/docs/advanced-concepts/attribute-transformers.yaml +151 -0
- package/public/rjbuild/docs/advanced-concepts/data-mapping.md +6 -6
- package/public/rjbuild/docs/advanced-concepts/data-mapping.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.md +7 -7
- package/public/rjbuild/docs/advanced-concepts/data-processors.yaml +7 -7
- package/public/rjbuild/docs/advanced-concepts/forward-update.md +82 -9
- package/public/rjbuild/docs/advanced-concepts/forward-update.yaml +83 -13
- 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/advanced-concepts/plugins/plugin-system.md +1 -1
- package/public/rjbuild/docs/advanced-concepts/plugins/plugin-system.yaml +1 -1
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/SetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/ToggleAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttribute.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.md +2 -0
- package/public/rjbuild/docs/core/action/Attribute/UnsetAttributeValue.yaml +2 -0
- package/public/rjbuild/docs/core/action/Attribute/index.md +121 -0
- package/public/rjbuild/docs/core/action/Attribute/index.yaml +77 -0
- package/public/rjbuild/docs/core/action/CustomEventListener.md +150 -0
- package/public/rjbuild/docs/core/action/CustomEventListener.yaml +158 -0
- package/public/rjbuild/docs/core/action/HashChangeListener.md +1 -1
- package/public/rjbuild/docs/core/action/HashChangeListener.yaml +1 -1
- package/public/rjbuild/docs/core/action/MessageListener.md +1 -1
- package/public/rjbuild/docs/core/action/MessageListener.yaml +1 -1
- package/public/rjbuild/docs/core/action/ReactOnEvent.md +3 -3
- package/public/rjbuild/docs/core/action/ReactOnEvent.yaml +3 -3
- package/public/rjbuild/docs/core/action/index.md +2 -1
- package/public/rjbuild/docs/core/action/index.yaml +2 -1
- package/public/rjbuild/docs/core/attributeTransformer/index.md +17 -0
- package/public/rjbuild/docs/core/attributeTransformer/index.yaml +24 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.md +101 -0
- package/public/rjbuild/docs/core/attributeTransformer/setAttributeValue.yaml +144 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.md +269 -0
- package/public/rjbuild/docs/core/attributeTransformer/toggleAttributeValue.yaml +247 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.md +114 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttribute.yaml +138 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.md +140 -0
- package/public/rjbuild/docs/core/attributeTransformer/unsetAttributeValue.yaml +187 -0
- package/public/rjbuild/docs/core/hook/index.md +38 -0
- package/public/rjbuild/docs/core/hook/index.yaml +44 -0
- package/public/rjbuild/docs/core/hook/usePagination.md +286 -0
- package/public/rjbuild/docs/core/hook/usePagination.yaml +319 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.md +130 -0
- package/public/rjbuild/docs/core/hook/useTransformedAttributes.yaml +164 -0
- package/public/rjbuild/docs/core/reaction/fetchData.md +25 -0
- package/public/rjbuild/docs/core/reaction/fetchData.yaml +30 -2
- package/public/rjbuild/docs/core/reaction/submitData.md +28 -0
- package/public/rjbuild/docs/core/reaction/submitData.yaml +32 -1
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# useTransformedAttributes
|
|
2
|
+
|
|
3
|
+
Applies attribute transformations based on configured transformers in plugins. This hook allows conditional modification of component attributes by applying a series of defined transformations.
|
|
4
|
+
|
|
5
|
+
## Hook Signature
|
|
6
|
+
|
|
7
|
+
```javascript
|
|
8
|
+
const transformedAttributes = useTransformedAttributes(attrsToTransform, transformProps)
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Parameters
|
|
12
|
+
|
|
13
|
+
- `attrsToTransform` (object): Raw attributes to transform
|
|
14
|
+
- `transformProps` (array, optional): Array of transformation definitions to apply
|
|
15
|
+
|
|
16
|
+
## Return Value
|
|
17
|
+
|
|
18
|
+
- `transformedAttributes` (object): Final attributes after applying transformations (spread on target element/component)
|
|
19
|
+
|
|
20
|
+
## How It Works
|
|
21
|
+
|
|
22
|
+
The hook follows this logic:
|
|
23
|
+
|
|
24
|
+
1. **Validation Check**: If `transformProps` is `undefined`, returns original attributes
|
|
25
|
+
2. **Transformer Retrieval**: Accesses transformers via `globalDataContext.plugins.attributeTransformer`
|
|
26
|
+
3. **Sequential Application**: Applies each transformation in defined order
|
|
27
|
+
4. **Conditional Validation**: Each transformation is validated before application via `isValid()`
|
|
28
|
+
5. **Accumulation**: Transformations are applied cumulatively
|
|
29
|
+
|
|
30
|
+
## Supported Transformer Types
|
|
31
|
+
|
|
32
|
+
The following transformers are available in the system:
|
|
33
|
+
|
|
34
|
+
### setAttributeValue
|
|
35
|
+
Sets an attribute value conditionally.
|
|
36
|
+
|
|
37
|
+
### toggleAttributeValue
|
|
38
|
+
Toggles between two values for an attribute.
|
|
39
|
+
|
|
40
|
+
### unsetAttribute
|
|
41
|
+
Completely removes an attribute.
|
|
42
|
+
|
|
43
|
+
### unsetAttributeValue
|
|
44
|
+
Removes an attribute value (sets to `undefined`).
|
|
45
|
+
|
|
46
|
+
## Example Usage
|
|
47
|
+
|
|
48
|
+
```jsx
|
|
49
|
+
import { useTransformedAttributes } from '@ea-lab/reactive-json';
|
|
50
|
+
|
|
51
|
+
const MyComponent = ({ props }) => {
|
|
52
|
+
const baseAttributes = {
|
|
53
|
+
className: "btn btn-primary",
|
|
54
|
+
disabled: false,
|
|
55
|
+
title: "Click me"
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const transformedAttributes = useTransformedAttributes(
|
|
59
|
+
baseAttributes,
|
|
60
|
+
props.attributeTransforms
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return <button {...transformedAttributes}>Submit</button>;
|
|
64
|
+
};
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## Transformation Configuration
|
|
68
|
+
|
|
69
|
+
```yaml
|
|
70
|
+
# Example configuration in RjBuild
|
|
71
|
+
- type: MyComponent
|
|
72
|
+
attributeTransforms:
|
|
73
|
+
- what: setAttributeValue
|
|
74
|
+
when: ~~.form.isSubmitting
|
|
75
|
+
is: true
|
|
76
|
+
attributeName: disabled
|
|
77
|
+
value: true
|
|
78
|
+
|
|
79
|
+
- what: toggleAttributeValue
|
|
80
|
+
when: ~~.theme
|
|
81
|
+
is: "dark"
|
|
82
|
+
attributeName: className
|
|
83
|
+
value1: "btn btn-primary"
|
|
84
|
+
value2: "btn btn-primary btn-dark"
|
|
85
|
+
|
|
86
|
+
- what: unsetAttribute
|
|
87
|
+
when: ~~.user.role
|
|
88
|
+
is: "guest"
|
|
89
|
+
attributeName: title
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Context Integration
|
|
93
|
+
|
|
94
|
+
The hook automatically uses:
|
|
95
|
+
|
|
96
|
+
- **GlobalDataContext**: For accessing plugins and global data
|
|
97
|
+
- **TemplateContext**: For condition evaluation in templates
|
|
98
|
+
|
|
99
|
+
## Transformation Validation
|
|
100
|
+
|
|
101
|
+
Each transformation is validated via the `isValid()` function which checks:
|
|
102
|
+
|
|
103
|
+
- The `when` condition against the `is` value
|
|
104
|
+
- Supported comparison operators
|
|
105
|
+
- Data availability in contexts
|
|
106
|
+
|
|
107
|
+
## Error Handling
|
|
108
|
+
|
|
109
|
+
The hook is designed to be resilient:
|
|
110
|
+
|
|
111
|
+
- **Missing Transformer**: Silently ignores the transformation
|
|
112
|
+
- **Failed Validation**: Ignores invalid transformation
|
|
113
|
+
- **Missing Plugins**: Returns original attributes
|
|
114
|
+
- **Missing Data**: Ignores transformations that cannot be evaluated
|
|
115
|
+
|
|
116
|
+
## Performance
|
|
117
|
+
|
|
118
|
+
- **Sequential Application**: Transformations applied in order with accumulation
|
|
119
|
+
- **Optimized Validation**: Invalid transformations ignored quickly
|
|
120
|
+
- **Reusability**: Hook can be called multiple times without performance impact
|
|
121
|
+
|
|
122
|
+
## Relationship with Transformers
|
|
123
|
+
|
|
124
|
+
This hook is closely related to the attributeTransformer system:
|
|
125
|
+
|
|
126
|
+
- Uses transformers registered in plugins
|
|
127
|
+
- Respects transformer syntax (`what`, `when`, `is` properties)
|
|
128
|
+
- Integrates with global validation system
|
|
129
|
+
|
|
130
|
+
For details on individual transformers, see [attributeTransformer documentation](../attributeTransformer/index.md).
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
renderView:
|
|
2
|
+
- type: Markdown
|
|
3
|
+
content: |
|
|
4
|
+
# useTransformedAttributes
|
|
5
|
+
|
|
6
|
+
Applies attribute transformations based on configured transformers in plugins. This hook allows conditional modification of component attributes by applying a series of defined transformations.
|
|
7
|
+
|
|
8
|
+
## Hook Signature
|
|
9
|
+
|
|
10
|
+
- type: SyntaxHighlighter
|
|
11
|
+
language: "javascript"
|
|
12
|
+
content: |
|
|
13
|
+
const transformedAttributes = useTransformedAttributes(attrsToTransform, transformProps)
|
|
14
|
+
|
|
15
|
+
- type: Markdown
|
|
16
|
+
content: |
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
- type: DefinitionList
|
|
20
|
+
content:
|
|
21
|
+
- term:
|
|
22
|
+
code: attrsToTransform
|
|
23
|
+
after: "(object)"
|
|
24
|
+
details: "Raw attributes to transform"
|
|
25
|
+
- term:
|
|
26
|
+
code: transformProps
|
|
27
|
+
after: "(array, optional)"
|
|
28
|
+
details: "Array of transformation definitions to apply"
|
|
29
|
+
|
|
30
|
+
- type: Markdown
|
|
31
|
+
content: |
|
|
32
|
+
## Return Value
|
|
33
|
+
|
|
34
|
+
- type: DefinitionList
|
|
35
|
+
content:
|
|
36
|
+
- term:
|
|
37
|
+
code: transformedAttributes
|
|
38
|
+
after: "(object)"
|
|
39
|
+
details: "Final attributes after applying transformations (spread on target element/component)"
|
|
40
|
+
|
|
41
|
+
- type: Markdown
|
|
42
|
+
content: |
|
|
43
|
+
## How It Works
|
|
44
|
+
|
|
45
|
+
The hook follows this logic:
|
|
46
|
+
|
|
47
|
+
1. **Validation Check**: If `transformProps` is `undefined`, returns original attributes
|
|
48
|
+
2. **Transformer Retrieval**: Accesses transformers via `globalDataContext.plugins.attributeTransformer`
|
|
49
|
+
3. **Sequential Application**: Applies each transformation in defined order
|
|
50
|
+
4. **Conditional Validation**: Each transformation is validated before application via `isValid()`
|
|
51
|
+
5. **Accumulation**: Transformations are applied cumulatively
|
|
52
|
+
|
|
53
|
+
## Supported Transformer Types
|
|
54
|
+
|
|
55
|
+
The following transformers are available in the system:
|
|
56
|
+
|
|
57
|
+
### setAttributeValue
|
|
58
|
+
Sets an attribute value conditionally.
|
|
59
|
+
|
|
60
|
+
### toggleAttributeValue
|
|
61
|
+
Toggles between two values for an attribute.
|
|
62
|
+
|
|
63
|
+
### unsetAttribute
|
|
64
|
+
Completely removes an attribute.
|
|
65
|
+
|
|
66
|
+
### unsetAttributeValue
|
|
67
|
+
Removes an attribute value (sets to `undefined`).
|
|
68
|
+
|
|
69
|
+
- type: Markdown
|
|
70
|
+
content: |
|
|
71
|
+
## Example Usage
|
|
72
|
+
|
|
73
|
+
- type: SyntaxHighlighter
|
|
74
|
+
language: "jsx"
|
|
75
|
+
content: |
|
|
76
|
+
import { useTransformedAttributes } from '@ea-lab/reactive-json';
|
|
77
|
+
|
|
78
|
+
const MyComponent = ({ props }) => {
|
|
79
|
+
const baseAttributes = {
|
|
80
|
+
className: "btn btn-primary",
|
|
81
|
+
disabled: false,
|
|
82
|
+
title: "Click me"
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const transformedAttributes = useTransformedAttributes(
|
|
86
|
+
baseAttributes,
|
|
87
|
+
props.attributeTransforms
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
return <button {...transformedAttributes}>Submit</button>;
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
- type: Markdown
|
|
94
|
+
content: |
|
|
95
|
+
## Transformation Configuration
|
|
96
|
+
|
|
97
|
+
- type: SyntaxHighlighter
|
|
98
|
+
language: "yaml"
|
|
99
|
+
content: |
|
|
100
|
+
# Example configuration in RjBuild
|
|
101
|
+
- type: MyComponent
|
|
102
|
+
attributeTransforms:
|
|
103
|
+
- what: setAttributeValue
|
|
104
|
+
when: ~~.form.isSubmitting
|
|
105
|
+
is: true
|
|
106
|
+
attributeName: disabled
|
|
107
|
+
value: true
|
|
108
|
+
|
|
109
|
+
- what: toggleAttributeValue
|
|
110
|
+
when: ~~.theme
|
|
111
|
+
is: "dark"
|
|
112
|
+
attributeName: className
|
|
113
|
+
value1: "btn btn-primary"
|
|
114
|
+
value2: "btn btn-primary btn-dark"
|
|
115
|
+
|
|
116
|
+
- what: unsetAttribute
|
|
117
|
+
when: ~~.user.role
|
|
118
|
+
is: "guest"
|
|
119
|
+
attributeName: title
|
|
120
|
+
|
|
121
|
+
- type: Markdown
|
|
122
|
+
content: |
|
|
123
|
+
## Context Integration
|
|
124
|
+
|
|
125
|
+
The hook automatically uses:
|
|
126
|
+
|
|
127
|
+
- **GlobalDataContext**: For accessing plugins and global data
|
|
128
|
+
- **TemplateContext**: For condition evaluation in templates
|
|
129
|
+
|
|
130
|
+
## Transformation Validation
|
|
131
|
+
|
|
132
|
+
Each transformation is validated via the `isValid()` function which checks:
|
|
133
|
+
|
|
134
|
+
- The `when` condition against the `is` value
|
|
135
|
+
- Supported comparison operators
|
|
136
|
+
- Data availability in contexts
|
|
137
|
+
|
|
138
|
+
## Error Handling
|
|
139
|
+
|
|
140
|
+
The hook is designed to be resilient:
|
|
141
|
+
|
|
142
|
+
- **Missing Transformer**: Silently ignores the transformation
|
|
143
|
+
- **Failed Validation**: Ignores invalid transformation
|
|
144
|
+
- **Missing Plugins**: Returns original attributes
|
|
145
|
+
- **Missing Data**: Ignores transformations that cannot be evaluated
|
|
146
|
+
|
|
147
|
+
## Performance
|
|
148
|
+
|
|
149
|
+
- **Sequential Application**: Transformations applied in order with accumulation
|
|
150
|
+
- **Optimized Validation**: Invalid transformations ignored quickly
|
|
151
|
+
- **Reusability**: Hook can be called multiple times without performance impact
|
|
152
|
+
|
|
153
|
+
## Relationship with Transformers
|
|
154
|
+
|
|
155
|
+
This hook is closely related to the attributeTransformer system:
|
|
156
|
+
|
|
157
|
+
- Uses transformers registered in plugins
|
|
158
|
+
- Respects transformer syntax (`what`, `when`, `is` properties)
|
|
159
|
+
- Integrates with global validation system
|
|
160
|
+
|
|
161
|
+
For details on individual transformers, see [attributeTransformer documentation](../attributeTransformer/index).
|
|
162
|
+
|
|
163
|
+
templates: {}
|
|
164
|
+
data: {}
|
|
@@ -27,6 +27,31 @@
|
|
|
27
27
|
- Without `updateDataAtLocation`: **completely replaces** the entire data object
|
|
28
28
|
- With `updateDataAtLocation`: updates only the specified path in the data
|
|
29
29
|
|
|
30
|
+
## Response Event
|
|
31
|
+
|
|
32
|
+
`fetchData` triggers a special `response` event when the HTTP request completes successfully. This allows you to process the response data immediately using other reactions.
|
|
33
|
+
|
|
34
|
+
You can use the `on: response` trigger with any reaction (like `setData`) to access the response data through the [forward update system](../../../advanced-concepts/forward-update.md):
|
|
35
|
+
|
|
36
|
+
```yaml
|
|
37
|
+
actions:
|
|
38
|
+
- what: fetchData
|
|
39
|
+
on: click
|
|
40
|
+
url: "/api/user-profile.json"
|
|
41
|
+
updateOnlyData: true
|
|
42
|
+
updateDataAtLocation: ~~.userProfile
|
|
43
|
+
- what: setData
|
|
44
|
+
on: response # Triggered when fetchData completes
|
|
45
|
+
path: ~~.userTheme
|
|
46
|
+
value: <reactive-json:event-new-value>.preferences.theme
|
|
47
|
+
- what: setData
|
|
48
|
+
on: response
|
|
49
|
+
path: ~~.lastFetchTime
|
|
50
|
+
value: <reactive-json:event-new-value>.metadata.timestamp
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
The response event provides access to the complete server response through `<reactive-json:event-new-value>`, allowing you to extract specific values and store them in different data locations.
|
|
54
|
+
|
|
30
55
|
> **⚠️ Important:** When using `updateOnlyData: true`, the server response must contain **data only**, not a complete RjBuild structure. The response should be the raw data object, not wrapped in `{data: {...}, renderView: [...], templates: {...}}`.
|
|
31
56
|
|
|
32
57
|
## Examples
|
|
@@ -56,6 +56,34 @@ renderView:
|
|
|
56
56
|
- Errors are only logged to the console
|
|
57
57
|
- The triggering element is visually disabled during the request
|
|
58
58
|
|
|
59
|
+
## Response Event
|
|
60
|
+
|
|
61
|
+
`fetchData` triggers a special `response` event when the HTTP request completes successfully. This allows you to process the response data immediately using other reactions.
|
|
62
|
+
|
|
63
|
+
You can use the `on: response` trigger with any reaction (like `setData`) to access the response data through the [forward update system](../../../advanced-concepts/forward-update):
|
|
64
|
+
|
|
65
|
+
- type: SyntaxHighlighter
|
|
66
|
+
language: yaml
|
|
67
|
+
content: |
|
|
68
|
+
actions:
|
|
69
|
+
- what: fetchData
|
|
70
|
+
on: click
|
|
71
|
+
url: "/api/user-profile.json"
|
|
72
|
+
updateOnlyData: true
|
|
73
|
+
updateDataAtLocation: ~~.userProfile
|
|
74
|
+
- what: setData
|
|
75
|
+
on: response # Triggered when fetchData completes
|
|
76
|
+
path: ~~.userTheme
|
|
77
|
+
value: <reactive-json:event-new-value>.preferences.theme
|
|
78
|
+
- what: setData
|
|
79
|
+
on: response
|
|
80
|
+
path: ~~.lastFetchTime
|
|
81
|
+
value: <reactive-json:event-new-value>.metadata.timestamp
|
|
82
|
+
|
|
83
|
+
- type: Markdown
|
|
84
|
+
content: |
|
|
85
|
+
The response event provides access to the complete server response through `<reactive-json:event-new-value>`, allowing you to extract specific values and store them in different data locations.
|
|
86
|
+
|
|
59
87
|
- type: RjBuildDescriber
|
|
60
88
|
title: Basic Structure (GET - Default)
|
|
61
89
|
description:
|
|
@@ -184,11 +212,11 @@ renderView:
|
|
|
184
212
|
title:
|
|
185
213
|
type: Markdown
|
|
186
214
|
content: |
|
|
187
|
-
Data-Only Update Examples
|
|
215
|
+
Data-Only Update Examples
|
|
188
216
|
description:
|
|
189
217
|
- type: Markdown
|
|
190
218
|
content: |
|
|
191
|
-
Properties `updateOnlyData` and `updateDataAtLocation`
|
|
219
|
+
Properties `updateOnlyData` and `updateDataAtLocation` allow for more precise data management:
|
|
192
220
|
|
|
193
221
|
- `updateOnlyData: true`: Only updates the data section, preserving templates and renderView
|
|
194
222
|
- `updateDataAtLocation`: Specifies exactly where to place the response data
|
|
@@ -29,6 +29,34 @@
|
|
|
29
29
|
- Without `updateDataAtLocation`: **completely replaces** the entire data object
|
|
30
30
|
- With `updateDataAtLocation`: updates only the specified path in the data
|
|
31
31
|
|
|
32
|
+
## Response Event
|
|
33
|
+
|
|
34
|
+
`submitData` triggers a special `response` event when the HTTP submission completes successfully. This allows you to process the response data immediately using other reactions.
|
|
35
|
+
|
|
36
|
+
You can use the `on: response` trigger with any reaction (like `setData`) to access the response data through the [forward update system](../../../advanced-concepts/forward-update.md):
|
|
37
|
+
|
|
38
|
+
```yaml
|
|
39
|
+
actions:
|
|
40
|
+
- what: submitData
|
|
41
|
+
on: click
|
|
42
|
+
url: "/api/user/save"
|
|
43
|
+
data:
|
|
44
|
+
name: ~.form.name
|
|
45
|
+
email: ~.form.email
|
|
46
|
+
updateOnlyData: true
|
|
47
|
+
updateDataAtLocation: ~~.userProfile
|
|
48
|
+
- what: setData
|
|
49
|
+
on: response # Triggered when submitData completes
|
|
50
|
+
path: ~~.lastSaveStatus
|
|
51
|
+
value: <reactive-json:event-new-value>.status
|
|
52
|
+
- what: setData
|
|
53
|
+
on: response
|
|
54
|
+
path: ~~.saveTimestamp
|
|
55
|
+
value: <reactive-json:event-new-value>.metadata.savedAt
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The response event provides access to the complete server response through `<reactive-json:event-new-value>`, allowing you to extract specific values and store them in different data locations independently of the main data update process.
|
|
59
|
+
|
|
32
60
|
> **⚠️ Important:** When using `updateOnlyData: true`, the server response must contain **data only**, not a complete RjBuild structure. The response should be the raw data object, not wrapped in `{data: {...}, renderView: [...], templates: {...}}`.
|
|
33
61
|
|
|
34
62
|
## Submission States & Styling
|
|
@@ -64,6 +64,37 @@ renderView:
|
|
|
64
64
|
- In case of an error, the submission is cancelled and logged to the console
|
|
65
65
|
- Interface elements are visually disabled during submission (unless `submitSilently` is enabled)
|
|
66
66
|
|
|
67
|
+
## Response Event
|
|
68
|
+
|
|
69
|
+
`submitData` triggers a special `response` event when the HTTP submission completes successfully. This allows you to process the response data immediately using other reactions.
|
|
70
|
+
|
|
71
|
+
You can use the `on: response` trigger with any reaction (like `setData`) to access the response data through the [forward update system](../../../advanced-concepts/forward-update):
|
|
72
|
+
|
|
73
|
+
- type: SyntaxHighlighter
|
|
74
|
+
language: yaml
|
|
75
|
+
content: |
|
|
76
|
+
actions:
|
|
77
|
+
- what: submitData
|
|
78
|
+
on: click
|
|
79
|
+
url: "/api/user/save"
|
|
80
|
+
data:
|
|
81
|
+
name: ~.form.name
|
|
82
|
+
email: ~.form.email
|
|
83
|
+
updateOnlyData: true
|
|
84
|
+
updateDataAtLocation: ~~.userProfile
|
|
85
|
+
- what: setData
|
|
86
|
+
on: response # Triggered when submitData completes
|
|
87
|
+
path: ~~.lastSaveStatus
|
|
88
|
+
value: <reactive-json:event-new-value>.status
|
|
89
|
+
- what: setData
|
|
90
|
+
on: response
|
|
91
|
+
path: ~~.saveTimestamp
|
|
92
|
+
value: <reactive-json:event-new-value>.metadata.savedAt
|
|
93
|
+
|
|
94
|
+
- type: Markdown
|
|
95
|
+
content: |
|
|
96
|
+
The response event provides access to the complete server response through `<reactive-json:event-new-value>`, allowing you to extract specific values and store them in different data locations independently of the main data update process.
|
|
97
|
+
|
|
67
98
|
## Submission States & Styling
|
|
68
99
|
The system uses a global locking mechanism to handle submissions:
|
|
69
100
|
- Only one submission can be active at a time for all application roots
|
|
@@ -165,7 +196,7 @@ renderView:
|
|
|
165
196
|
- Save progression state
|
|
166
197
|
- Maintain consistency between client and server
|
|
167
198
|
|
|
168
|
-
## Data-Only Update Examples
|
|
199
|
+
## Data-Only Update Examples
|
|
169
200
|
|
|
170
201
|
The properties `updateOnlyData` and `updateDataAtLocation` work identically for `submitData` and `fetchData`.
|
|
171
202
|
|