Dialog shennanegins

CCalego12/10/2021
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()
CCalego12/10/2021
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();
Aarcanist12/10/2021
Can you pass the html between the two as well?
CCalego12/10/2021
Yeah! the argument of the callback is the html
CCalego12/10/2021
const annoying = () => Dialog.confirm({
  content: "Press yes or I come back.",
  no: annoying
});

annoying();
CCalego12/10/2021
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."]);