<commit_before>var EventEmitter    = require("../core/eventEmitter"),
protoclass          = require("protoclass"),
watchProperty       = require("./watchProperty");

/** 
 * @module mojo
 * @submodule mojo-core
 */

/**

BindableObjects make it easy to link properties of two separate objects - when one changes, 
the other will automatically update with that change. It enables much easier interactions between data models and UIs, 
among other uses outside of MVC.

<br> 
<br>

BindableObjects provide a way to maintain the state between server <-> client for a realtime front-end 
application (similar to Firebase), or perhaps a way to communicate between server <-> server for a realtime distributed Node.js 
application.


### Example

```javascript
  var bindable = require("bindable");

  var person = new bindable.Object({
    name: "craig",
    last: "condon",
    location: {
      city: "San Francisco"
    }
  });

  person.bind("location.zip", function(value) {
    // 94102
  }).now();

  //triggers the binding
  person.set("location.zip", "94102"); 

  //bind location.zip to another property in the model, and do it only once
  person.bind("location.zip", { to: "zip", max: 1 }).now();

  //bind location.zip to another object, and make it bi-directional.
  person.bind("location.zip", { target: anotherModel, to: "location.zip", bothWays: true }).now();

  //chain to multiple items, and limit it!
  person.bind("location.zip", { to: ["property", "anotherProperty"], max: 1 }).now();


  //you can also transform data as it's being bound
  person.bind("name", {
    to: "name2",
    map: function (name) {
      return name.toUpperCase();
    }
  }).now();
```

@class BindableObject
@extends EventEmitter<commit_msg>remove tab<commit_after>var EventEmitter    = require("../core/eventEmitter"),
protoclass          = require("protoclass"),
watchProperty       = require("./watchProperty");

/** 
 * @module mojo
 * @submodule mojo-core
 */

/**

BindableObjects make it easy to link properties of two separate objects - when one changes, 
the other will automatically update with that change. It enables much easier interactions between data models and UIs, 
among other uses outside of MVC.

<br> 
<br>

BindableObjects provide a way to maintain the state between server <-> client for a realtime front-end 
application (similar to Firebase), or perhaps a way to communicate between server <-> server for a realtime distributed Node.js 
application.


### Example

```javascript
var bindable = require("bindable");

var person = new bindable.Object({
  name: "craig",
  last: "condon",
  location: {
    city: "San Francisco"
  }
});

person.bind("location.zip", function(value) {
  // 94102
}).now();

//triggers the binding
person.set("location.zip", "94102"); 

//bind location.zip to another property in the model, and do it only once
person.bind("location.zip", { to: "zip", max: 1 }).now();

//bind location.zip to another object, and make it bi-directional.
person.bind("location.zip", { target: anotherModel, to: "location.zip", bothWays: true }).now();

//chain to multiple items, and limit it!
person.bind("location.zip", { to: ["property", "anotherProperty"], max: 1 }).now();


//you can also transform data as it's being bound
person.bind("name", {
  to: "name2",
  map: function (name) {
    return name.toUpperCase();
  }
}).now();
```

@class BindableObject
@extends EventEmitter
{'fraction_non_alphanumeric': 0.13587115666178623, 'fraction_numerical': 0.007613469985358712, 'mean_word_length': 3.784313725490196, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2838516', 'n_tokens_mistral': 1036, 'n_tokens_neox': 992, 'n_words': 366}