Dialog shennanegins

TIL the button callbacks for Dialog.prompt and Dialog.confirm can be asynchronous.
const foo = async () => {
const response = await Dialog.prompt({
title: "Confirmation Title",
content: "Are you sure about that?",
callback: async (html) => { return 'foo' },
});

console.log('responded', response); // 'foo' when the button is pressed
};

foo()
const foo = async () => {
const response = await Dialog.prompt({
title: "Confirmation Title",
content: "Are you sure about that?",
callback: async (html) => { return 'foo' },
});

console.log('responded', response); // 'foo' when the button is pressed
};

foo()
5 Replies
Calego
Calego3y ago
const refrain = () => Dialog.prompt({
content: "It just goes on and on my friends.",
callback: chorus
});

const chorus = () => Dialog.prompt({
content: "This is the song that never ends.",
callback: refrain
});

chorus();
const refrain = () => Dialog.prompt({
content: "It just goes on and on my friends.",
callback: chorus
});

const chorus = () => Dialog.prompt({
content: "This is the song that never ends.",
callback: refrain
});

chorus();
No description
Daniel Thorp
Daniel Thorp3y ago
Can you pass the html between the two as well?
Calego
Calego3y ago
Yeah! the argument of the callback is the html
Calego
Calego3y ago
const annoying = () => Dialog.confirm({
content: "Press yes or I come back.",
no: annoying
});

annoying();
const annoying = () => Dialog.confirm({
content: "Press yes or I come back.",
no: annoying
});

annoying();
No description
Calego
Calego3y ago
hard to see what's happening here, but each one is actually adding one to the nested dom stack.
function outerHTML(node){
return node.outerHTML || new XMLSerializer().serializeToString(node);
}

const inception = (html) => Dialog.prompt({
content: html[0] instanceof Node ? outerHTML(html[0]) : html[0],
callback: inception
});


inception(["We have to go deeper."]);
function outerHTML(node){
return node.outerHTML || new XMLSerializer().serializeToString(node);
}

const inception = (html) => Dialog.prompt({
content: html[0] instanceof Node ? outerHTML(html[0]) : html[0],
callback: inception
});


inception(["We have to go deeper."]);
No description