Skip to content

Instantly share code, notes, and snippets.

@icylace
Created February 22, 2022 09:39
Show Gist options
  • Save icylace/d7ee0079c83a9089cca379cf7a7ce42c to your computer and use it in GitHub Desktop.
Save icylace/d7ee0079c83a9089cca379cf7a7ce42c to your computer and use it in GitHub Desktop.
Diagram of Hyperapp

Diagram of Hyperapp

For context:

graph TD

viewEvent["view event"]
viewEvent -->|"dispatch"| Action

init(("init:"))
init ---|"is set as"| j0[ ] --- j1[ ] --- j2[ ] --> oneOf

userInteraction(("user<br>interaction"))
userInteraction -->|"onclick"| viewEvent
userInteraction -->|"onmousemove"| subscription

externalEvents(("external<br>events"))
externalEvents -->|"onEvent"| subscription

subscription -->|"dispatch"| Action

Action ---|"returns"| j3[ ] --> oneOf

oneOf{"one of"}
oneOf -->|"Action<br/>[Action, payload?]"| Action
oneOf -->|"{state}"| nextState
oneOf ---|"[state, effect(s)]"| j4[ ]

j4 --> nextState
j4 --> effect

nextState["set next<br>state"]
nextState --- j5[ ] -->|"view(state)"| renderDom
nextState -->|"subscriptions(state)"| refreshSubs

renderDom(("(re)render<br>DOM"))

effect["effect(s)"]
effect -->|"upon execution"| runEffect

runEffect(("run<br>effect(s)"))
runEffect -.-|"dispatch"| j6

refreshSubs["refresh<br>subscription(s)"]
refreshSubs -->|"upon cancellation"| cleanSubs

cleanSubs(("clean<br>cancelled<br>subscription(s)"))
cleanSubs -.-|"dispatch"| j6

j6[ ] -.-> Action

style j0 height:0;
style j1 height:0;
style j2 height:0;
style j3 height:0;
style j4 height:0;
style j5 height:0;
style j6 height:0;
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment