profelis / bindx2 Goto Github PK
View Code? Open in Web Editor NEWCrossplatform library for data binding in Haxe
License: MIT License
Crossplatform library for data binding in Haxe
License: MIT License
Any plans on supporting bindx's bindxGlobal and unbindxGlobal?
Hi,
Thanks for the great lib - thinking about using it for haxeui, however, i think im running into a macro build order issue and wondering what advice you might have about how to avoid it. Consider (there is a bit of noise here):
class Component implements IBindable {
public function new() {
}
}
class Slider extends Component {
@:bindable public var pos:Float = 0;
public function new() {
super();
}
}
@:build(ComponentMacros.build())
class CustomComponent extends Component {
public var theSlider:Slider = new Slider();
@:bind(theSlider.pos) public var someValue:Float = 0;
public function new() {
super();
Bind.bindTo(this.someValue, this.theSlider.pos);
Bind.bindTo(this.theSlider.pos, this.someValue);
}
}
And the ComponentMacros.build()
is pretty simple:
var bindableFields = Macros.getFieldsWithMeta("bind", fields);
for (f in bindableFields) {
f.meta.push( { name: ":bindable", pos: pos, params: [] });
}
In essence, what im trying to do is add the :bindable
meta data as part of the macro (so that i can use my own :bind(...)
meta to link things together. However, i get the error:
BindSignalProvider.hx:65: characters 42-59 : CustomComponent has no field someValueChanged
If i add the @:bindable
meta on the someVar
then everything is fine. Presumably because some part of the bindx macro system hasnt run yet? Do you have any advice on this?
Thanks in advance,
Ian
For example (pseudo code):
class A implements IBindable {
@:bindable
public var valueA:String;
}
class B extends A {
@:bindable
public var valueB:String;
}
...
var b = new B();
Bind.bindAll(b, handleChanges);
Function handleChanges works only for B class fields. It because of haxe.rtti.Meta.getFields method (Returns the metadata that were declared for the given class fields).
... because Context.onMacroContextReused is deprecated.
Bind.unbindAll removes all callbacks.
Need function to remove only one exact callback. I say about the following:
Bind.unbindAll(obj:IBindable, listener)
I'm still trying to replace the old bindx in my project with this one but it is still lacking some features of the previous version.
I quickly tested by modifying line 105 and 109 of BindSignal like this:
var listener = function (from, to) callback(name, from, to);
var listener = function () callback(name, null, null);
Thanks for the bindAll though!
How can I unbind after using Bind.bindTo(instance.value, instance2.value) ?
Having some trouble understanding how to use lazySignal. My goal would be to have defaults in a class, and then use a Bind.bind() to automatically call initialization functions. Bind.notify works, but in a more complex application it could signal things I do not expect (or just be redundant).
I created a simple test below. Switching lazySignal true or false does not fire the boolChanged function either way. Maybe I misunderstand, any help is appreciated.
import bindx.*;
class Main implements IBindable {
@:bindable(lazySignal = false)
var someBool:Bool = false;
static function main() {
var m = new Main();
Bind.notify(m.someBool, false, false); // notify can be used, but it would be great to have Bind.bind send a signal to the new listener only
}
function new() {
Bind.bind(this.someBool, boolChanged); // Any way to make this signal/dispatch immediately?
}
function boolChanged(from:Bool, to:Bool) {
trace("HERE");
}
}
The README says that bindable interfaces are supported. Can you please tell me what is wrong with my example code?
$ haxe -D bindx_log=2 -lib bindx2 -main Main --interp
/Users/rkissh/haxelib/bindx2/2,6,2/src/bindx/macro/BindSignalProvider.hx:64: characters 20-37 : IRick has no field aChanged
Main.hx:34: characters 4-25 : Called from macro here
/Users/rkissh/haxelib/bindx2/2,6,2/src/bindx/macro/BindSignalProvider.hx:65: characters 42-59 : IRick has no field aChanged
Main.hx:34: characters 4-25 : Called from macro here
import bindx.IBindable;
import bindx.Bind;
@:bindable interface IRick extends IBindable {
var a(get,set):Int;
}
@:bindable private class Rick implements IRick {
public var a(get,set):Int;
private var _a:Int = 0;
public function new() {
}
private function get_a():Int {
return _a;
}
private function set_a(value:Int):Int {
_a = value;
return value;
}
}
private class View {
public var b:Int = 0;
public function new() {
}
}
class Main {
static public function main():Void {
var r:IRick = new Rick();
var v = new View();
Bind.bindTo(r.a, v.b);
r.a = 8;
trace("v.b = " + v.b);
}
}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.