Coder Social home page Coder Social logo

Comments (3)

ogoffart avatar ogoffart commented on August 23, 2024

They could return a Future such as slint::JoinHandle.
This would unfortunately be a breaking change, I think. So If we want to have support of this before Slint 2.0, it would need to be another function name.

from slint.

ogoffart avatar ogoffart commented on August 23, 2024

Note that the code that you wrote with an atomic will not work, because the callback will be run in another thread and can be run after you check the cancelled

As of now, you can use tokio channel.

For example (untested, please let me know if you find mistakes)

let (tx, rx) = tokio::sync::mpsc::channel(1);
dialog_weak.upgrade_in_event_loop(move |dialog| {
   let c = dalog.get_cancelled();
   tx.send(c).unwrap();
}).unwrap();

let cancelled = rx.recv().await.unwrap();

You can use std's channel if you don't want to use async channel.

from slint.

npwoods avatar npwoods commented on August 23, 2024

Yes, I learned (the hard way) that what I proposed wouldn't work - and yes there are plenty of ways to snake a return value out of such a callback, but none of them would be as convenient as a hypothetical invoke_from_event_loop_with_retval() function or the equivalent.

I'll defer to you guys what should happen to this specific GitHub issue

from slint.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.