Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

437 lines (436 sloc) 12.221 kB
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>CoffeeScript API Documentation</title>
<link rel='stylesheet' href='../../assets/codo.css' type='text/css'>
<script src='../../assets/codo.js'></script>
<script src='../../assets/search_data.js'></script>
</head>
<body>
<div id='base' data-path='../../'></div>
<div id='header'>
<div id='menu'>
<a href='../../class_index.html' title='Index'>Index</a>
&raquo;
<a href='../../classes/kb.html' title='kb'>kb</a>
&raquo;
<span class='title'>Store</span>
<nav>
<ul>
<li class='noframes'>
(<a class='noframes' href='#'>no frames</a>)
</li>
</ul>
</nav>
<div id='search'>
<a id='class_list_link' href='../../class_list.html'>Classes</a>
<a id='method_list_link' href='../../method_list.html'>Methods</a>
<a id='extra_list_link' href='../../extra_list.html'>Extras</a>
</div>
</div>
<iframe id='search_frame'></iframe>
<div id='fuzzySearch'>
<input type='text'>
<ol></ol>
</div>
<div id='help'>
<p>
Quickly fuzzy find classes, mixins, methods, file:
</p>
<ul>
<li>
<span>Ctrl-T</span>
Open fuzzy finder dialog
</li>
</ul>
<p>
In frame mode you can toggle the list naviation frame on the left side:
</p>
<ul>
<li>
<span>Ctrl-L</span>
Toggle list view
</li>
</ul>
<p>
You can focus a list in frame mode or toggle a tab in frameless mode:
</p>
<ul>
<li>
<span>Ctrl-C</span>
Class list
</li>
<li>
<span>Ctrl-I</span>
Mixin list
</li>
<li>
<span>Ctrl-F</span>
File list
</li>
<li>
<span>Ctrl-M</span>
Method list
</li>
<li>
<span>Ctrl-E</span>
Extras list
</li>
</ul>
<p>
You can focus and blur the search input:
</p>
<ul>
<li>
<span>Ctrl-S</span>
Focus search input
</li>
<li>
<span>Esc</span>
Blur search input
</li>
</ul>
<p>
In frameless mode you can close the list tab:
</p>
<ul>
<li>
<span>Esc</span>
Close list tab
</li>
</ul>
</div>
</div>
<div id='content'>
<h1>
Class:
kb.Store
</h1>
<table class='box'>
<tr>
<td>Defined in:</td>
<td>src/knockback-core/knockback-store.coffee</td>
</tr>
</table>
<h2>Overview</h2>
<div class='docstring'>
<p>Used to share and manage the persistence of ViewModels and observables. ks.Store can be used to break relationship cycles between models, to reduce memory usage, and to share view models between kb.CollectionObservables (for example, when using Knockout.js selectedOptions). </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
How to create a ko.CollectionObservable using the ko.collectionObservable factory.
</h4>
<pre><code class='coffee'>var co = kb.collectionObservable(new Backbone.Collection());
var co_selected_options = kb.collectionObservable(new Backbone.Collection(), {
store: kb.utils.wrappedStore(co)
});</code></pre>
</div>
</div>
<div class='tags'>
</div>
<h2>Class Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#useOptionsOrCreate-class'>
+ (void) <strong>useOptionsOrCreate</strong>(options, obj, observable)
</a>
</span>
<span class='desc'>
Used to either register yourself with the existing store or to create a new store.
</span>
</li>
</ul>
<h2>Instance Method Summary</h2>
<ul class='summary'>
<li>
<span class='signature'>
<a href='#constructor-instance'>
- (void) <strong>constructor</strong>()
</a>
</span>
<span class='constructor note title'>Constructor</span>
<span class='desc'>
Used to create a new kb.Store.
</span>
</li>
<li>
<span class='signature'>
<a href='#destroy-instance'>
- (void) <strong>destroy</strong>()
</a>
</span>
<span class='desc'>
Required clean up function to break cycles, release view models, etc.
</span>
</li>
<li>
<span class='signature'>
<a href='#register-instance'>
- (void) <strong>register</strong>(obj, observable, options)
</a>
</span>
<span class='desc'>
Used to register a new view model with the store.
</span>
</li>
<li>
<span class='signature'>
<a href='#findOrCreate-instance'>
- (void) <strong>findOrCreate</strong>(obj, options)
</a>
</span>
<span class='desc'>
Used to find an existing observable in the store or create a new one if it doesn't exist.
</span>
</li>
</ul>
<h2>Class Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='useOptionsOrCreate-class'>
+ (void) <strong>useOptionsOrCreate</strong>(options, obj, observable)
</p>
<div class='docstring'>
<p>Used to either register yourself with the existing store or to create a new store. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
</h4>
<pre><code class='coffee'>kb.Store.useOptionsOrCreate(model, this, options);
</code></pre>
</div>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>options</span>
<span class='type'>
(<tt>Object</tt>)
</span>
&mdash;
<span class='desc'>please pass the options from your constructor to the register method. For example, constructor(model, options)</span>
</li>
<li>
<span class='name'>obj</span>
<span class='type'>
(<tt>Instance</tt>)
</span>
&mdash;
<span class='desc'>the instance that will own or register with the store</span>
</li>
<li>
<span class='name'>observable</span>
<span class='type'>
(<tt>ko.observable</tt>)
</span>
&mdash;
<span class='desc'>the observable that will own the store</span>
</li>
</ul>
</div>
</div>
</div>
<h2>Constructor Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='constructor-instance'>
- (void) <strong>constructor</strong>()
</p>
<div class='docstring'>
<p>Used to create a new kb.Store. </p>
</div>
<div class='tags'>
</div>
</div>
</div>
<h2>Instance Method Details</h2>
<div class='methods'>
<div class='method_details'>
<p class='signature' id='destroy-instance'>
- (void) <strong>destroy</strong>()
</p>
<div class='docstring'>
<p>Required clean up function to break cycles, release view models, etc. Can be called directly, via kb.release(object) or as a consequence of ko.releaseNode(element). </p>
</div>
<div class='tags'>
</div>
</div>
<div class='method_details'>
<p class='signature' id='register-instance'>
- (void) <strong>register</strong>(obj, observable, options)
</p>
<div class='docstring'>
<p>Used to register a new view model with the store. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
register an observable with th store
</h4>
<pre><code class='coffee'>store.registerObservable(obj, observable, {creator: creator});
</code></pre>
</div>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>obj</span>
<span class='type'>
(<tt>Backbone.Model</tt>)
</span>
&mdash;
<span class='desc'>the Backbone.Model</span>
</li>
<li>
<span class='name'>observable</span>
<span class='type'>
(<tt>ko.observable</tt>)
</span>
&mdash;
<span class='desc'>the observable to share for the Backbone.Model</span>
</li>
<li>
<span class='name'>options</span>
<span class='type'>
(<tt>Object</tt>)
</span>
&mdash;
<span class='desc'>please pass the options from your constructor to the register method. For example, constructor(model, options)</span>
</li>
</ul>
<h3>
Options Hash:
(options):
</h3>
<ul class='options'>
<li>
<span class='name'>creator</span>
<span class='type'>
(<tt>Constructor|Function</tt>)
</span>
&mdash;
<span class='desc'>the constructor or function used to create the observable. It is used to match observables in the store.</span>
</li>
<li>
<span class='name'>path</span>
<span class='type'>
(<tt>String</tt>)
</span>
&mdash;
<span class='desc'>the path to the value (used to create related observables from the factory).</span>
</li>
<li>
<span class='name'>store</span>
<span class='type'>
(<tt><a href='../../classes/kb/Store.html'>kb.Store</a></tt>)
</span>
&mdash;
<span class='desc'>a store used to cache and share view models.</span>
</li>
<li>
<span class='name'>factory</span>
<span class='type'>
(<tt><a href='../../classes/kb/Factory.html'>kb.Factory</a></tt>)
</span>
&mdash;
<span class='desc'>a factory used to create view models.</span>
</li>
</ul>
</div>
</div>
<div class='method_details'>
<p class='signature' id='findOrCreate-instance'>
- (void) <strong>findOrCreate</strong>(obj, options)
</p>
<div class='docstring'>
<p>Used to find an existing observable in the store or create a new one if it doesn&#39;t exist. </p>
<div class='examples'>
<h3>Examples:</h3>
<h4>
register an observable with th store
</h4>
<pre><code class='coffee'>observable = store.findOrCreateObservable(value, {path: kb.utils.wrappedPath(observable), factory: kb.utils.wrappedFactory(observable)})
</code></pre>
</div>
</div>
<div class='tags'>
<h3>Parameters:</h3>
<ul class='param'>
<li>
<span class='name'>obj</span>
<span class='type'>
(<tt>Backbone.Model|Backbone.Collection|Data</tt>)
</span>
&mdash;
<span class='desc'>the object to create the observable for. Only Backbone.Models are cached in the store.</span>
</li>
<li>
<span class='name'>options</span>
<span class='type'>
(<tt>Object</tt>)
</span>
&mdash;
<span class='desc'>please pass the options from your constructor to the register method. For example, constructor(model, options)</span>
</li>
</ul>
<h3>
Options Hash:
(options):
</h3>
<ul class='options'>
<li>
<span class='name'>creator</span>
<span class='type'>
(<tt>Constructor|Function</tt>)
</span>
&mdash;
<span class='desc'>the constructor or function used to create the observable. It is used to match observables in the store.</span>
</li>
<li>
<span class='name'>path</span>
<span class='type'>
(<tt>String</tt>)
</span>
&mdash;
<span class='desc'>the path to the value (used to create related observables from the factory).</span>
</li>
<li>
<span class='name'>store</span>
<span class='type'>
(<tt><a href='../../classes/kb/Store.html'>kb.Store</a></tt>)
</span>
&mdash;
<span class='desc'>a store used to cache and share view models.</span>
</li>
<li>
<span class='name'>factory</span>
<span class='type'>
(<tt><a href='../../classes/kb/Factory.html'>kb.Factory</a></tt>)
</span>
&mdash;
<span class='desc'>a factory used to create view models.</span>
</li>
</ul>
</div>
</div>
</div>
</div>
<div id='footer'>
Generated on
Thu Sep 06 2012 17:22:43 GMT+0900 (JST)
by
<a href='https://github.com/netzpirat/codo' title='CoffeeScript API documentation generator'>Codo</a>
v1.3.0
(Node.js v0.8.7).
&#10034;
Press Ctrl-h to see the keyboard shortcuts
&#10034;
<a href='http://twitter.com/#!/netzpirat'>@netzpirat</a>
&#10034;
<a href='https://mksoft.ch'>mksoft.ch</a>
</div>
</body>
</html>
Jump to Line
Something went wrong with that request. Please try again.