Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
export default () => {
const queue = []
let then
return {
onbeforeupdate : () => !blocker,
oncreate : resolve,
onupdate : resolve,
view : ({
instance,
children: [now],
attrs : {onchange = () => {}},
}) => {
let output = [[now]]
onchange({
now,
then,
go: guard(async directive => {
output = [[then], [now]]
await queue(directive)
}),
})
return output
},
}
function resolve(now){
if(resolution)
resolution(now.dom)
}
function guard(directive){
return async () => {
if(resolution)
return console.error(
`Resolution directives must be executed synchronously.`
)
if(blocker)
return console.error(
`Resolution directives are mutually exclusive.`
)
blocker = directive
await directive()
blocker = false
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.