You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81-81Lines changed: 81 additions & 81 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -27,7 +27,7 @@ This add on attemps to solve 2 things:
27
27
1. Reduce boilerplate by auto dispatching Request, Success, and Failure Events
28
28
2. Be FSA Compliant
29
29
30
-
In order to be FSA Compliant, most of the information is stored in the `meta` object.
30
+
In order to be FSA Compliant, most of the information is stored in the `meta` object.
31
31
32
32
33
33
# The Simple Way (`{string} endpoint`)
@@ -36,7 +36,7 @@ In order to be FSA Compliant, most of the information is stored in the `meta` ob
36
36
37
37
Wraps an action creator so that its return value is the payload of a Flux Standard Action, and also creates multiple actions types that can be handled via middleware (Request, Success, and Failure Types).
38
38
39
-
The parameters you pass to your action are **verb dependant**
39
+
The parameters you pass to your action are **verb dependant**
40
40
41
41
Also adds `meta` data, such as the `method` and `endpoint` to be used where you see fit.
42
42
@@ -49,16 +49,16 @@ Example:
49
49
let createContact =createAPIAction('CREATE_CONTACT', 'POST', '/contacts' );
In the event of an `UPDATE`, you generally need to specify 2 pieces
149
+
In the event of an `UPDATE`, you generally need to specify 2 pieces
150
150
* id of item you are updating
151
151
* the data you want to update with
152
152
153
153
In this case, we are updating primary item `15` with a new object
154
154
155
-
*Auto Generated Action Types*
156
-
-`ITEMS_PUT_REQUEST`
157
-
-`ITEMS_PUT_SUCCESS`
155
+
*Auto Generated Action Types*
156
+
-`ITEMS_PUT_REQUEST`
157
+
-`ITEMS_PUT_SUCCESS`
158
158
-`ITEMS_PUT_FAILURE`
159
159
160
-
**Sample**
160
+
**Sample**
161
161
162
162
```json
163
163
{
164
-
type: 'ITEMS',
165
-
payload: {
166
-
name: 'james'
164
+
"type": "ITEMS",
165
+
"payload": {
166
+
"name": "james"
167
167
},
168
-
meta: {
169
-
api: true,
170
-
method: 'PUT',
171
-
endpoint: '/sample/10',
172
-
types: [
173
-
'ITEMS_PUT_REQUEST',
174
-
'ITEMS_PUT_SUCCESS',
175
-
'ITEMS_PUT_FAILURE'
168
+
"meta": {
169
+
"api": true,
170
+
"method": "PUT",
171
+
"endpoint": "/sample/10",
172
+
"types": [
173
+
"ITEMS_PUT_REQUEST",
174
+
"ITEMS_PUT_SUCCESS",
175
+
"ITEMS_PUT_FAILURE"
176
176
]
177
177
}
178
-
}
178
+
}
179
179
```
180
180
181
181
### DELETE
@@ -187,25 +187,25 @@ updateItem(15);
187
187
In the case of `DELETE`, you just need to specify the primary id of tha which you want to delete.
188
188
No need to pass in any payload data, as that would get dropped anyways because of `DELETE`
189
189
190
-
*Auto Generated Action Types*
191
-
-`ITEMS_DELETE_REQUEST`
192
-
-`ITEMS_DELETE_SUCCESS`
190
+
*Auto Generated Action Types*
191
+
-`ITEMS_DELETE_REQUEST`
192
+
-`ITEMS_DELETE_SUCCESS`
193
193
-`ITEMS_DELETE_FAILURE`
194
194
195
-
**Sample**
195
+
**Sample**
196
196
197
197
```json
198
198
{
199
-
type: 'ITEMS',
200
-
payload: {},
201
-
meta: {
202
-
api: true,
203
-
method: 'DELETE',
204
-
endpoint: '/sample/5',
205
-
types: [
206
-
'ITEMS_DELETE_REQUEST',
207
-
'ITEMS_DELETE_SUCCESS',
208
-
'ITEMS_DELETE_FAILURE'
199
+
"type": "ITEMS",
200
+
"payload": {},
201
+
"meta": {
202
+
"api": true,
203
+
"method": "DELETE",
204
+
"endpoint": "/sample/5",
205
+
"types": [
206
+
"ITEMS_DELETE_REQUEST",
207
+
"ITEMS_DELETE_SUCCESS",
208
+
"ITEMS_DELETE_FAILURE"
209
209
]
210
210
}
211
211
}
@@ -216,13 +216,13 @@ No need to pass in any payload data, as that would get dropped anyways because o
216
216
217
217
In cases where you need to customize the endpoint with more granularity, you can pass a `function` as the `endpoint` instead of a string. This gives you access to the payload so you can create dynamic endpoints based on the payload.
218
218
219
-
NOTE: When using the Advanced method, you only need to send a payload across. In the Simple version, parameter order is important (IE: for PUTs, first parameter is ID, second is payload, for POST the parameter is the payload).
219
+
NOTE: When using the Advanced method, you only need to send a payload across. In the Simple version, parameter order is important (IE: for PUTs, first parameter is ID, second is payload, for POST the parameter is the payload).
220
220
221
221
For the advanced version, you only need to send the payload, and your endpoint will return dynamically based on your function.
0 commit comments