Skip to content

Instantly share code, notes, and snippets.

@mindrones
Created July 16, 2019 09:56
Show Gist options
  • Save mindrones/1783f9ea8411c227e4629d9f663e6b50 to your computer and use it in GitHub Desktop.
Save mindrones/1783f9ea8411c227e4629d9f663e6b50 to your computer and use it in GitHub Desktop.
Generated by XState Viz: https://xstate.js.org/viz
Machine({
"id": "search",
"type": "parallel",
"states": {
"Search": {
"id": "Search",
"initial": "Empty",
"states": {
"Empty": {
"id": "Empty",
"on": {
"QUERY_ENTERED": {
"target": "NotEmpty"
}
}
},
"NotEmpty": {
"id": "NotEmpty",
"initial": "Dirty",
"on": {
"QUERY_CLEARED": {
"target": "#Empty"
},
"QUERY_MATCHED": {
"target": "#Matching"
},
"QUERY_CHANGED": {
"target": "#Dirty"
}
},
"states": {
"Matching": {
"id": "Matching",
"onEntry": "shareMatching"
},
"Dirty": {
"id": "Dirty",
"initial": "Idle",
"onEntry": "shareDirty",
"on": {
"SEARCHED": {
"target": "Dirty.Pending"
}
},
"states": {
"Idle": {},
"Pending": {
"onEntry": "sharePending",
"invoke": {
"id": "Pending",
"src": "apiRequest",
"onDone": {
"target": "#Matching",
"actions": [
"updateData",
"shareSuccess"
]
},
"onError": {
"target": "#Error"
}
}
},
"Error": {
"id": "Error",
"onEntry": "shareError"
}
}
}
}
}
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment