Skip to content

Instantly share code, notes, and snippets.

@RoyalIcing
Last active June 2, 2022 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RoyalIcing/3bbba165ec282edf707894cb1f8f053c to your computer and use it in GitHub Desktop.
Save RoyalIcing/3bbba165ec282edf707894cb1f8f053c to your computer and use it in GitHub Desktop.
State Machine for simplified version of React’s rendering model
export function* ReactComponent() {
function* Initial() {
yield on("render", Rendering);
}
function* Rendering() {
yield on("resourceSuspended", Suspended);
yield on("error", Errored);
yield on("commit", Committed);
}
function* Suspended() {
yield on("promiseResolved", Rendering);
}
function* Errored() {
yield on("render", Rendering);
}
function* Committed() {
yield on("render", Rendering);
}
return Initial;
}
@RoyalIcing
Copy link
Author

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment