Last active
December 23, 2021 19:53
-
-
Save Tiagoperes/704d3c9512f4d3fd95eb331de400812b to your computer and use it in GitHub Desktop.
loading, error, success example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_beagleComponent_": "beagle:container", | |
"context": { | |
"id": "status", | |
"value": "loading" | |
}, | |
"onInit": [ | |
{ | |
"_beagleAction_": "beagle:sendRequest", | |
"url": "https://gist.githubusercontent.com/Tiagoperes/704d3c9512f4d3fd95eb331de400812b/raw/f6c8a515792f879ba4078cd5008421ab066aabe4/success.json", | |
"onSuccess": [ | |
{ | |
"_beagleAction_": "beagle:addChildren", | |
"componentId": "successContainer", | |
"mode": "REPLACE", | |
"value": "@{onSuccess.data}" | |
}, | |
{ | |
"_beagleAction_": "beagle:setContext", | |
"contextId": "status", | |
"value": "success" | |
} | |
], | |
"onError": [ | |
{ | |
"_beagleAction_": "beagle:setContext", | |
"contextId": "status", | |
"value": "error" | |
} | |
] | |
} | |
], | |
"children": [ | |
{ | |
"_beagleComponent_": "beagle:container", | |
"id": "loadingContainer", | |
"style": { | |
"display": "@{condition(eq(status, 'loading'), 'FLEX', 'NONE')}" | |
}, | |
"children": [ | |
{ | |
"_beagleComponent_": "beagle:text", | |
"text":"Loading..." | |
} | |
] | |
}, | |
{ | |
"_beagleComponent_": "beagle:container", | |
"style": { | |
"display": "@{condition(eq(status, 'success'), 'FLEX', 'NONE')}" | |
}, | |
"id": "successContainer" | |
}, | |
{ | |
"_beagleComponent_": "beagle:container", | |
"id": "errorContainer", | |
"style": { | |
"display": "@{condition(eq(status, 'error'), 'FLEX', 'NONE')}" | |
}, | |
"children": [ | |
{ | |
"_beagleComponent_": "beagle:text", | |
"text": "THIS IS AN ERROR" | |
}, | |
{ | |
"_beagleComponent_": "beagle:button", | |
"text": "Retry", | |
"onPress": [ | |
{ | |
"_beagleAction_": "beagle:setContext", | |
"contextId": "status", | |
"value": "loading" | |
}, | |
{ | |
"_beagleAction_": "beagle:sendRequest", | |
"url": "https://gist.githubusercontent.com/Tiagoperes/704d3c9512f4d3fd95eb331de400812b/raw/f6c8a515792f879ba4078cd5008421ab066aabe4/success.json", | |
"onSuccess": [ | |
{ | |
"_beagleAction_": "beagle:addChildren", | |
"componentId": "successContainer", | |
"mode": "REPLACE", | |
"value": "@{onSuccess.data}" | |
}, | |
{ | |
"_beagleAction_": "beagle:setContext", | |
"contextId": "status", | |
"value": "success" | |
} | |
], | |
"onError": [ | |
{ | |
"_beagleAction_": "beagle:setContext", | |
"contextId": "status", | |
"value": "error" | |
} | |
] | |
} | |
] | |
} | |
] | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_beagleComponent_": "beagle:container", | |
"children": [ | |
{ | |
"_beagleComponent_": "beagle:text", | |
"text": "This is a successful result!" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment