Skip to content

Instantly share code, notes, and snippets.

@Tiagoperes
Last active December 23, 2021 19:53
Show Gist options
  • Save Tiagoperes/704d3c9512f4d3fd95eb331de400812b to your computer and use it in GitHub Desktop.
Save Tiagoperes/704d3c9512f4d3fd95eb331de400812b to your computer and use it in GitHub Desktop.
loading, error, success example
{
"_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"
}
]
}
]
}
]
}
]
}
{
"_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