Coder Social home page Coder Social logo

bradparks / bindx Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hxjointforces/bindx

0.0 1.0 0.0 125 KB

Powerful and fast macro-based data binding engine inspired by Flex Bindings with easy-to-use syntax.

Home Page: http://lib.haxe.org/p/bindx

bindx's Introduction

bindx

Powerful and fast macro-based data binding engine inspired by Flex Bindings with easy-to-use syntax.

====

Basic Usage

Bind field

@bindable class Value implements IBindable {
	
	public var a:Int;
	
	public function new() {
		
	}
}

...

using bindx.Bind;
...

var v = new Value();
v.a = 12;

var a = { t:0 };
var unbindTo = v.a.bindxTo(a.t); // a.t == 12

var unbind = v.a.bindx(function (from:Int, to:Int) { trace('v.a changed from:$from to:$to'); } );
v.a = 10; // v.a changed from 12 to 10

unbind();
unbindTo();

Bind method

using bindx.Bind;

class Value implements IBindable {
	
	@bindable public var a:Int;
	
	@bindable public function toString() {
		return Std.string("Value: a=" + a);
	
	public function update() {
		toString.notify();  // bindx.Bind.notify(this.toString);
	}
	
	public function new() {
		
	}
}

...

using bindx.Bind;
...

var v = new Value();
v.a = 12;

var unbind = v.toString.bindx(function (res:String) { trace(res); } ); // Value: a=12

v.a = 0;
v.update(); // Value: a=0

v.a = 5;
v.toString.notify(); // Value: a=5

unbind();

Recursive fields and methods bind https://github.com/HxJointForces/bindx/blob/master/test/main/TestDeepBind.hx

bindx's People

Contributors

bsideup avatar profelis avatar

Watchers

 avatar

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.