Code Monkey home page Code Monkey logo

bindx2's People

Contributors

aartzrc avatar mpoint4u avatar profelis avatar realyuniquename avatar sinnus 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bindx2's Issues

Global binding

Any plans on supporting bindx's bindxGlobal and unbindxGlobal?

Macro build order

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

Bind.bindAll doesn't work properly for inherited classes

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).

bindAll should provide old and new values like the regular bind method

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!

unbind method

How can I unbind after using Bind.bindTo(instance.value, instance2.value) ?

Trouble with lazySignal

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");
    }
}

How to use bindable interfaces

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);
  }
}

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.