ink-docstrap
Version:
[](https://nodei.co/npm/ink-docstrap/)
1,270 lines (533 loc) • 21.6 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8">
<title>DocStrap Module: documents/binder</title>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
<link type="text/css" rel="stylesheet" href="styles/site.cerulean.css">
</head>
<body>
<div class="container-fluid">
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<a class="brand" href="index.html">DocStrap</a>
<ul class="nav">
<li class="dropdown">
<a href="modules.list.html" class="dropdown-toggle" data-toggle="dropdown">Modules<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="module-base.html">base</a>
</li>
<li>
<a href="chains_.html">base/chains</a>
</li>
<li>
<a href="binder.html">documents/binder</a>
</li>
<li>
<a href="model_.html">documents/model</a>
</li>
<li>
<a href="probe.html">documents/probe</a>
</li>
<li>
<a href="schema_.html">documents/schema</a>
</li>
<li>
<a href="collector.html">ink/collector</a>
</li>
<li>
<a href="bussable_.html">mixins/bussable</a>
</li>
<li>
<a href="signalable_.html">mixins/signalable</a>
</li>
<li>
<a href="format.html">strings/format</a>
</li>
<li>
<a href="logger.html">utils/logger</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="base.html">base</a>
</li>
<li>
<a href="chains.html">base/chains</a>
</li>
<li>
<a href="model.html">documents/model</a>
</li>
<li>
<a href="probe.queryOperators.html">queryOperators</a>
</li>
<li>
<a href="probe.updateOperators.html">updateOperators</a>
</li>
<li>
<a href="collector-ACollector.html">ACollector</a>
</li>
<li>
<a href="collector-CollectorBase_.html">CollectorBase</a>
</li>
<li>
<a href="collector-OCollector.html">OCollector</a>
</li>
<li>
<a href="signalable-Signal.html">Signal</a>
</li>
<li>
<a href="logger.Logger.html">Logger</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="mixins.list.html" class="dropdown-toggle" data-toggle="dropdown">Mixins<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="schema.html">documents/schema</a>
</li>
<li>
<a href="bussable.html">mixins/bussable</a>
</li>
<li>
<a href="signalable.html">mixins/signalable</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="tutorials.list.html" class="dropdown-toggle" data-toggle="dropdown">Tutorials<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="tutorial-Teeth.html">Brush Teeth</a>
</li>
<li>
<a href="tutorial-Car.html">Drive Car</a>
</li>
<li>
<a href="tutorial-Test.html">Fence Test</a>
</li>
</ul>
</li>
<li class="dropdown">
<a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b
class="caret"></b></a>
<ul class="dropdown-menu ">
<li>
<a href="global.html#utils/logger">utils/logger</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
<div class="row-fluid">
<div class="span8">
<div id="main">
<h1 class="page-title">Module: documents/binder</h1>
<section>
<header>
<h2>
documents/binder
</h2>
</header>
<article>
<div class="container-overview">
<div class="description"><p>allows you to bind a change watcher that looks for get and set operations on an arbitrary
property of an object at at any depth. This allows you to look for changes or intercept values asynchronously or otherwise.</p></div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="binder.js.html">documents/binder.js</a>,
<a href="binder.js.html#sunlight-1-line-2">line 2</a>
</li>
</ul>
</dd>
</dl>
</div>
<h3 class="subsection-title">Requires</h3>
<ul>
<li>module:async</li>
<li><a href="probe.html">module:documents/probe</a></li>
<li>module:lodash</li>
<li>module:promise</li>
</ul>
<h3 class="subsection-title">Methods</h3>
<dl>
<dt>
<h4 class="name" id="bind"><span class="type-signature"><static> </span>bind<span class="signature">(path, record, options)</span><span class="type-signature"> → {*}</span></h4>
</dt>
<dd>
<div class="description">
<p>Bind to a property somewhere in an object. The property is found using dot notation and can be arbitrarily deep.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The path into the object to locate the property. For instance this could be <code>"_id"</code>, <code>"name.last"</code>.
or <code>"some.really.really.long.path.including.an.array.2.name"</code></p></td>
</tr>
<tr>
<td class="name"><code>record</code></td>
<td class="type">
<span class="param-type">object</span>
</td>
<td class="description last"><p>Anything you can hang a property off of</p></td>
</tr>
<tr>
<td class="name"><code>options</code></td>
<td class="type">
<span class="param-type">options</span>
</td>
<td class="description last"><p>What you wanna do with the doohicky when yoyu bind it.</p>
<h6>Properties</h6>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>getter</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>This is the method to run when getting the value. When it runs, you will receive
a single parameter which is the current value as the object understands it. You can return the value directly, just raise an event or
whatever your little heart demands. However, if you are asynchronous, this will turn your return value into a promise, one of the
few places this system will embrace promises over node-like error passing and that is mainly because this is a getter so a return value
is particularly important. *</p>
<h6>Properties</h6>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>value</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The current value of the record</p></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>When asynchronous, return you value through this method using node style
error passing (the promise is handled for you by this method).</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>getterAsync</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>When true (not truthy) the getter is treated asynchronously and returns a promise with your value.</p></td>
</tr>
<tr>
<td class="name"><code>setter</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>A setter method</p>
<h6>Properties</h6>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>newVal</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>The new value</p></td>
</tr>
<tr>
<td class="name"><code>oldVal</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>The old value</p></td>
</tr>
<tr>
<td class="name"><code>record</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>The record hosting the change</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>validator</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>If you want a validator to run before settings values, pass this guy in</p>
<h6>Properties</h6>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Argument</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>newVal</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The new value</p></td>
</tr>
<tr>
<td class="name"><code>oldVal</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The old value</p></td>
</tr>
<tr>
<td class="name"><code>record</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="attributes">
</td>
<td class="description last"><p>The record hosting the change</p></td>
</tr>
<tr>
<td class="name"><code>callback</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>If the validator is asynchronous, then pass your value back here, otherwise pass it back as a return value.
When you use an asynchronous instance, pass the error in the first value and then the rest of the parameters are yours to play with</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
<tr>
<td class="name"><code>validatorAsync</code></td>
<td class="type">
<span class="param-type">boolean</span>
</td>
<td class="attributes">
<optional><br>
</td>
<td class="description last"><p>When true (not truthy) the validator is treated asynchornously and returns a promise with your value.</p></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="binder.js.html">documents/binder.js</a>,
<a href="binder.js.html#sunlight-1-line-92">line 92</a>
</li>
</ul>
</dd>
</dl>
<h5>Returns:</h5>
<dl>
<dt>
Type
</dt>
<dd>
<span class="param-type">*</span>
</dd>
</dl>
</dd>
<dt>
<h4 class="name" id="unbind"><span class="type-signature"><static> </span>unbind<span class="signature">(path, record)</span><span class="type-signature"></span></h4>
</dt>
<dd>
<div class="description">
<p>You can unbind previously bound objects from here.</p>
</div>
<h5>Parameters:</h5>
<table class="params table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>path</code></td>
<td class="type">
<span class="param-type">string</span>
</td>
<td class="description last"><p>The path that was bound using <a href="binder.html#bind">module:documents/binder.bind</a></p></td>
</tr>
<tr>
<td class="name"><code>record</code></td>
<td class="type">
<span class="param-type">*</span>
</td>
<td class="description last"><p>The object that was bound</p></td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source">
<ul class="dummy">
<li>
<a href="binder.js.html">documents/binder.js</a>,
<a href="binder.js.html#sunlight-1-line-36">line 36</a>
</li>
</ul>
</dd>
</dl>
</dd>
</dl>
</article>
</section>
</div>
<div class="clearfix"></div>
<footer>
<span class="copyright">
DocStrap Copyright © 2012-2013 The contributors to the JSDoc3 and DocStrap projects.
</span>
<br />
<span class="jsdoc-message">
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a>
on Sun Jun 1st 2014 using the <a
href="https://github.com/terryweiss/docstrap">DocStrap template</a>.
</span>
</footer>
</div>
<div class="span3">
<div id="toc"></div>
</div>
<br clear="both">
</div>
</div>
<!--<script src="scripts/sunlight.js"></script>-->
<script src="scripts/docstrap.lib.js"></script>
<script src="scripts/bootstrap-dropdown.js"></script>
<script src="scripts/toc.js"></script>
<script>
$( function () {
$( "#toc" ).toc( {
anchorName : function ( i, heading, prefix ) {
return $( heading ).attr( "id" ) || ( prefix + i );
},
selectors : "h1,h2,h3,h4",
showAndHide : false,
scrollTo : 60
} );
$( "#toc>ul" ).addClass( "nav nav-pills nav-stacked" );
$( "#main span[id^='toc']" ).addClass( "toc-shim" );
// $( ".tutorial-section pre, .readme-section pre" ).addClass( "sunlight-highlight-javascript" ).addClass( "linenums" );
$( ".tutorial-section pre, .readme-section pre" ).each( function () {
var $this = $( this );
var example = $this.find("code" );
exampleText = example.html();
var lang = /{@lang (.*?)}/.exec( exampleText );
if ( lang && lang[1] ) {
exampleText = exampleText.replace( lang[0], "" );
example.html(exampleText);
lang = lang[1];
} else {
lang = "javascript";
}
if ( lang ) {
$this
.addClass( "sunlight-highlight-" + lang )
.addClass( "linenums" )
.html( example.html() );
}
} );
Sunlight.highlightAll( {
lineNumbers : true,
showMenu:true,
enableDoclinks:true
} );
} );
</script>
<!--Google Analytics-->
<!--Navigation and Symbol Display-->
</body>
</html>