Bindable
A data binding library for Haxe and MXHX.
Minimum Requirements
- Haxe 4.0
Installation
This library is not yet available on Haxelib, so you'll need to install it from Github.
haxelib git bindable https://github.com/mxhx-dev/bindable.git
Project Configuration
After installing the library above, add it to your Haxe .hxml file.
--library bindable
OpenFL or Lime
For Lime and OpenFL, add it to your project.xml file instead.
<haxelib name="bindable" />
Usage
The first argument is the source of the data. The second is the destination. The final argument is a display object where the binding should be activated when it is added to the stage, and deactivated when it is removed.
DataBinding.bind(Std.string(slider.value), label.text, this);
C++
When Haxe creates a release build for the cpp target, it omits certain null checks by default. This configuration can lead to segmentation faults when accessing fields on null objects, instead of an exception that can be caught, like other targets.
There are a couple of different ways to workaround this quirk.
-
Adding the
HXCPP_CHECK_POINTERdefine to your project's configuration to enable the missingnullchecks. -
If using Haxe 4.3 or newer, using the safe navigation operator to manually handle
nullobjects.
`haxe
DataBinding.bind(obj?.prop, dest, this);`