EasyUI Forum
April 18, 2024, 08:51:48 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Feature request: Messager async/await return  (Read 1424 times)
chrwei
Full Member
***
Posts: 219


View Profile Email
« on: September 16, 2022, 09:35:39 AM »

I'm currently doing this to async/await Messager dialogs calls.  (this is in a functional component with useRef() )

Code:
let res = await new Promise(resolve => {
  messager.current.confirm({
    title: "Question",
    msg: "Do you like async/await?",
    buttons: [
      { text: "yes", value: true },
      { text: "no", value: false },
    ],
    result: r => {
      resolve(r);
    }
  });
});

Would it be possible to add an async/await pattern when the "result" callback isn't provided?  Examples for how that would be called:

Code:
let res = await messager.current.confirm({
  title: "Question",
  msg: "Do you like async/await?",
  buttons: [
    { text: "yes", value: true },
    { text: "no", value: false },
  ],
});

or

Code:
let answer = await messager.current.confirm({
  title: "Question",
  msg: "Do you like async/await?",
  buttons: [
    { text: "yes", value: true },
    { text: "no", value: false },
  ],
}).then(r=> {
  return r ? "I like it" : "I can do without"
});

Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!