GithubHelp home page GithubHelp logo

kdbindings's People

Contributors

frankosterfeld avatar ivan-cukic avatar lemirep avatar leonmatthes avatar leonmattheskdab avatar mikom avatar pppberlin avatar seanharmer avatar tokoe-kdab avatar winterz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

kdbindings's Issues

Draft - Multi-Threaded bindings

Use Thread 1 with normal signal evaluation to mark a binding as dirty.

Then have all the dependent properties associated with a BindingEvaluator.
This binding evaluator would then be evaluated by Thread 2 (typically GUI Thread), so the evaluation actually happens on a separate thread.

For this to work the following would need to be thread-safe:

  1. Marking of a binding as dirty.
  2. Reading from a Property & updating the bindings internal cache
  3. Disconnecting/Connecting of Signals when creating a Binding

Add include paths with capitalised paths

It would be nice to be able to do:

#include <KDBindings/signal.h>

on systems with case-sensitive filesystems so that it matches the other KD libraries that we have.

Clazy never fails CI

Even if clazy generates warnings in CI the runner isn't considered to have failed.
How do we fix this?

Handling of members of aggregate types

When T is an aggregate type, eg struct Rect { int x; int y; int width; int height; }

It would be great to be able to access members of Property, i.e that:

Property<Rect> r;
auto widthProp = makeBoundProperty(r.width);

This slightly overlaps with what @lemirep is asking about in #28, except in my case the aggregate does not contain Property<> members. The desired behaviour can be done using a function argument to makeBoundProperty : the question is whether some overload of operator-dot (and ->, presumably) could synthesise the access.

Add `[[warn_unused_result]]` for ConnectionHandle

Forgetting to disconnect a connection can lead to serious issues.

So we should allow users to at least get a warning in that case.

However, we likely want to put this behind a flag of some sort to not break existing code.

Draft - Deferred connection evaluation

Having the ability to control when a connection is emitted could be advantageous, especially in a multi-threaded context, where a worker thread might emit a signal, but the slot should be called in an event loop on a GUI thread.

To control when exactly a connection is evaluated, implement a ConnectionEvaluator, similar to the BindingEvaluator, that can control when exactly a slot is called.

Add a function connectDeferred (or similar) that takes a ConnectionEvaluator as the first argument, then takes the same arguments as the normal connect function.
This slot would then queue the actual function to be called in the ConnectionEvaluator. The queued functions in the ConnectionEvaluator could then be called at any time, similar to how evaluateAll works on the BindingEvaluator.
The difference here would be that connections might actually be emitted multiple times between calls to the evaluator, so these calls would then also need to be emitted multiple times.

Draft - Single Shot Connection

A single shot connection could possibly be implemented by creating a binding that captures its own ConnectionHandle and disconnects it when the signal is emitted.

Open question: How to capture the ConnectionHandle in the slot itself?

Property move constructor cannot promise noexcept

The move constructor of Property is marked noexcept, but - as long as it emmits public moved signal - it can throw from any slot. Simple example:

TEST_CASE("Nothrow move")
{
    try {
        std::set_terminate([] {
            std::cerr << "TERMINATED" << std::endl;
        });
        Property<int> p;
        p.moved().connect([&] { throw 0; });

        Property<int> p2 = std::move(p);
    } catch (int) {
    }
}

The program will call std::terminate as it throws from noexcept function.

Handle Cascading Bindings

Often, I have to deal with a Property<T*> p where T itself contains properties. Given the property p is using a pointer type, I cannot binding directly to p->someProperty given p might be null. Therefore I would need to have a way to create a binding to a function that can itself return binding to another property or a value depending on whether p() is null.

// GIVEN
struct TypeA {
Property<float> value { 1.0f };
};

struct TypeB {
Property<TypeA *> a { nullptr };
};

// WHEN
TypeB myB;

// In a perfect world I would do Property<float> v = makeBinding(myB.a->value);
// Except I can't if myB.a is null

// THEN
CHECk(myB.a() == nullptr);

// WHEN
Property<float> v = makeBinding([] (TypeA *a) { 
                                    if (a)
                                       return makeBinding(a->value);
                                    return 0.0f; // or a binding to a default property
                                }, myB.a);

// THEN -> Returns default value
CHECK(v() == 0.0f);

// WHEN
TypeA myA;
myB.a = &myA;

// THEN -> Return bound value
CHECK(v() == 1.0f);

Allow having bindings referencing const Properties

At the moment I cannot use a const Property in a binding.

const Property<float> someValue = makeBinding(someExpression);
Property<float> boundValue = makeBinding(someValue); // This does not compile

A const Property means it cannot be assigned to again but its value still might change (if the value of the const property is a binding). Therefore, being able to use a const Property in a binding would make sense.

Add logging when dequeuing a deferred emission

It may be unexpected for users that a signal emission doesn't reach its slot when an emission is still queued up on disconnect.

Therefore, document that this is happening by adding some kind of logging.

Assuming #41 is merged with this behavior.

multithreading support

Can we achieve following in KDBindings?

  1. signal in thread1 and slots in thread2
  2. can it support something Qt provides ? QueuedConnection or BlockingQueuedConnection connection types?

Basically wanted to check if KDBindings support multithreaded property binding evaluation?

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.