On Monday, 13 July 2015 at 22:07:11 UTC, Tanel Tagaväli wrote:
Does the standard library have a way to create a forward link between two variables of the same type?
One variable is the source and the other is the sink.
When the source variable is changed, the sink variable is too.
Changing the sink variable has no effect on the source variable.

I have already implemented it using std.signals and class templates(https://github.com/TheBlu/lockd/blob/master/source/engine.d), but is there a better way, either in the standard library or a third party library?

I have done a data binding system using properties in my D learning library.

(https://github.com/BBasile/iz/blob/master/import/iz/properties.d#L610)

The problem encountered with data binding is that there must be a signal. So the most obvious way to do that is always more or less based on the observer pattern.

But there are other solutions:
- check a list of pointer in a thread or in a timer. (foreach target in targets...if target != source... ; Thread.sleep();) - check a list of pointer when a particular message is found within a message queue. (if messages.peek == msg.synchronize_bindings then foreach target in targets...) - similarly, check the target "on idle", for example on windows when no message is dispatched then an idleEvent can be defined. This solution works fine with GUI programs.

A very D-ish way to do that would be to use UDA annotations to build the list of targets.
  • Linked variables via Digitalmars-d-learn
    • Re: Linked variables Baz via Digitalmars-d-learn

Reply via email to