GithubHelp home page GithubHelp logo

Draft - Single Shot Connection about kdbindings HOT 4 CLOSED

kdab avatar kdab commented on July 22, 2024
Draft - Single Shot Connection

from kdbindings.

Comments (4)

phyBrackets avatar phyBrackets commented on July 22, 2024

I'm a bit confused about this, don't we need a special method for single shot connection, like singleShotConnect ? that gets disconnected after emit, which could be easily implemented just by having a set flag isSingleShot in singleShotConnect and each time when emit gets called, it should check that emit was on a single shot connection and if that's the case immediately disconnects it? Don't need to get around connection handle.

from kdbindings.

LeonMatthesKDAB avatar LeonMatthesKDAB commented on July 22, 2024

That should work as well. I was just thinking that something like this should maybe be possible:

mySignal.connect([](const auto &handle) {
    // do thing
    handle.disconnect();
});

More of a thought experiment than anything substantial. An approach like that wouldn't need another connect function and seems kind of elegantly recursive almost. It would even allow you to block the connect after it's first emitted, instead of disconnecting. It could then be unblocked again without having to reconnect. Might be useful for rate-limiting 🤔

But it's also incompatible with the current connect function I think, so don't know if it's worth continuing down.

Introducing a singleshotConnect function definitely works as well, so that's the more likely route to go down.
Though something like connectReflective would be cool, that allows you to reach your own ConnectionHandle...
That might run into weird lifetime issues though, where a lambda is deleted while in use, which could get quite hairy...

Anyhow, some food for thought.

from kdbindings.

LeonMatthesKDAB avatar LeonMatthesKDAB commented on July 22, 2024

The basics of reflective connections were layed out in #23, so we may want to revisit this idea :)

from kdbindings.

Related Issues (13)

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.