Skip to content

Commit c20c799

Browse files
author
Vlad Balin
committed
Merge branch 'master' of https://github.com/Volicon/Type-R
# Conflicts: # docs/Collection/Iteration_methods.html # docs/Collection/Overview.html # docs/Collection/Proxied_array_methods.html # docs/Collection/Serialization.html # docs/Collection/Sorted_collections.html # docs/Collection/Updates_and_Events.html # docs/Collection/Validation.html # docs/Events.html # docs/General_concepts/Aggregation_tree.html # docs/General_concepts/Overview.html # docs/General_concepts/Serialization.html # docs/General_concepts/Updates_and_change_events.html # docs/General_concepts/Validation.html # docs/Getting_Started.html # docs/Mixins.html # docs/Overview.html # docs/Record/Aggregation_tree.html # docs/Record/Overview.html # docs/Record/Serialization.html # docs/Record/Updates_and_change_events.html # docs/Record/Validation.html # docs/Record/id_ and_id-references.html # docs/themes/package.json # docs/tipuesearch/tipuesearch_content.json
2 parents c828291 + 71c30b8 commit c20c799

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+375
-416
lines changed

docs/Collection/Iteration_methods.html

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -76,33 +76,31 @@
7676

7777
<div class="Page__header">
7878
<h1>Iteration methods</h1>
79-
<span style="float: left; font-size: 10px; color: gray;">
80-
Saturday, May 20, 2017 3:49 PM </span>
8179
<span style="float: right; font-size: 10px; color: gray;">
8280
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/02_Iteration_methods.md" target="_blank">Edit on GitHub</a>
8381
</span>
8482
</div>
8583

8684

8785
<div class="s-content">
88-
<h2 id="page_map+and+forEach">map and forEach</h2>
89-
<h4 id="page_collection.forEach%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+void%2C+context%3F+%29">collection.forEach( iteratee : ( val : Record, index ) =&gt; void, context? )</h4>
90-
<h4 id="page_collection.each%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+void%2C+context%3F+%29">collection.each( iteratee : ( val : Record, index ) =&gt; void, context? )</h4>
86+
<h1 id="page_map+and+forEach">map and forEach</h1>
87+
<h3 id="page_collection.forEach%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+void%2C+context%3F+%29">collection.forEach( iteratee : ( val : Record, index ) =&gt; void, context? )</h3>
88+
<h3 id="page_collection.each%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+void%2C+context%3F+%29">collection.each( iteratee : ( val : Record, index ) =&gt; void, context? )</h3>
9189
<p>Iterate through the elements of the collection. Similar to <code>Array.forEach</code>.</p>
92-
<h4 id="page_collection.updateEach%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+void%2C+context%3F+%29">collection.updateEach( iteratee : ( val : Record, index ) =&gt; void, context? )</h4>
90+
<h3 id="page_collection.updateEach%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+void%2C+context%3F+%29">collection.updateEach( iteratee : ( val : Record, index ) =&gt; void, context? )</h3>
9391
<p>Similar to the <code>collection.each</code>, but wraps an iteration in a transaction. The single <code>changes</code> event will be emitted
9492
for the group of changes to the records made in <code>updateEach</code>.</p>
9593
<p><em>Use this method if you modify records in a loop</em>.</p>
96-
<h4 id="page_collection.map%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+T%2C+context%3F+%29">collection.map( iteratee : ( val : Record, index ) =&gt; T, context? )</h4>
94+
<h3 id="page_collection.map%28+iteratee+%3A+%28+val+%3A+Record%2C+index+%29+%3D%3E+T%2C+context%3F+%29">collection.map( iteratee : ( val : Record, index ) =&gt; T, context? )</h3>
9795
<p>Map elements of the collection. Similar to <code>Array.map</code>, but <code>undefined</code> values returned by iteratee are filtered out.</p>
9896
<p>Thus, <code>collection.map</code> can be used to map and filter elements in a single pass.</p>
99-
<h2 id="page_Predicate+methods">Predicate methods</h2>
97+
<h1 id="page_Predicate+methods">Predicate methods</h1>
10098
<p>Predicate is either the iteratee function returning boolean, or an object with attribute values used to match with record's attributes.</p>
101-
<h4 id="page_collection.filter%28+iteratee+%3A+Predicate%2C+context%3F+%29">collection.filter( iteratee : Predicate, context? )</h4>
99+
<h3 id="page_collection.filter%28+iteratee+%3A+Predicate%2C+context%3F+%29">collection.filter( iteratee : Predicate, context? )</h3>
102100
<p>Return filtered array of records matching the predicate.</p>
103-
<h4 id="page_collection.every%28+iteratee+%3A+Predicate%2C+context%3F+%29+%3A+boolean">collection.every( iteratee : Predicate, context? ) : boolean</h4>
101+
<h3 id="page_collection.every%28+iteratee+%3A+Predicate%2C+context%3F+%29+%3A+boolean">collection.every( iteratee : Predicate, context? ) : boolean</h3>
104102
<p>Return <code>true</code> if all records match the predicate.</p>
105-
<h4 id="page_collection.some%28+iteratee+%3A+Predicate%2C+context%3F+%29+%3A+boolean">collection.some( iteratee : Predicate, context? ) : boolean</h4>
103+
<h3 id="page_collection.some%28+iteratee+%3A+Predicate%2C+context%3F+%29+%3A+boolean">collection.some( iteratee : Predicate, context? ) : boolean</h3>
106104
<p>Return <code>true</code> if at least one record match the predicated.</p>
107105
</div>
108106

docs/Collection/Overview.html

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676

7777
<div class="Page__header">
7878
<h1>Overview</h1>
79-
<span style="float: left; font-size: 10px; color: gray;">
80-
Saturday, May 20, 2017 3:49 PM </span>
8179
<span style="float: right; font-size: 10px; color: gray;">
8280
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/00_Overview.md" target="_blank">Edit on GitHub</a>
8381
</span>
@@ -111,22 +109,22 @@ <h1>Overview</h1>
111109
}
112110
}
113111
</code></pre>
114-
<h2 id="page_Declarations">Declarations</h2>
115-
<h4 id="page_model+%3D+RecordConstructor"><code>static</code> model = RecordConstructor</h4>
112+
<h1 id="page_Declarations">Declarations</h1>
113+
<h3 id="page_model+%3D+RecordConstructor"><code>static</code> model = RecordConstructor</h3>
116114
<pre><code class="language-javascript">@define
117115
class Library extends Record.Collection {
118116
static model = Book;
119117
}
120118
</code></pre>
121119
<p>If defined, you can pass raw attributes objects (and arrays) to add, create, and reset, and the attributes will be converted into a model of the proper type.</p>
122120
<p>This property is being set automatically for collection types referenced as <code>MyRecord.Collection</code>. In the majority of cases you don't need to define it explicitly.</p>
123-
<h2 id="page_Members">Members</h2>
124-
<h4 id="page_constructor%28+models%3F%2C+options%3F+%29">constructor( models?, options? )</h4>
121+
<h1 id="page_Members">Members</h1>
122+
<h3 id="page_constructor%28+models%3F%2C+options%3F+%29">constructor( models?, options? )</h3>
125123
<p>When creating a Collection, you may choose to pass in the initial array of models. The collection's comparator may be included as an option. Passing false as the comparator option will prevent sorting. If you define an initialize function, it will be invoked when the collection is created. There are a couple of options that, if provided, are attached to the collection directly: model and comparator.
126124
Pass null for models to create an empty Collection with options.</p>
127125
<pre><code class="language-javascript">var tabs = new TabSet([tab1, tab2, tab3]);
128126
</code></pre>
129-
<h4 id="page_collection.add%28+models%2C+options%3F+%29">collection.add( models, options? )</h4>
127+
<h3 id="page_collection.add%28+models%2C+options%3F+%29">collection.add( models, options? )</h3>
130128
<p>Add a record (or an array of records) to the collection, firing an &quot;add&quot; event for each record, and an &quot;update&quot; event afterwards. If a record property is defined, you may also pass raw attributes objects, and have them be vivified as instances of the record. Returns the added (or preexisting, if duplicate) records. Pass {at: index} to splice the record into the collection at the specified index. If you're adding records to the collection that are already in the collection, they'll be ignored, unless you pass {merge: true}, in which case their attributes will be merged into the corresponding records, firing any appropriate &quot;change&quot; events.</p>
131129
<pre><code>var ships = new Backbone.Collection;
132130

@@ -141,9 +139,9 @@ <h4 id="page_collection.add%28+models%2C+options%3F+%29">collection.add( models,
141139
</code></pre>
142140
<p>Note that adding the same record (a record with the same id) to a collection more than once
143141
is a no-op.</p>
144-
<h4 id="page_collection.remove%28+records%2C+options%3F+%29">collection.remove( records, options? )</h4>
142+
<h3 id="page_collection.remove%28+records%2C+options%3F+%29">collection.remove( records, options? )</h3>
145143
<p>Remove a record (or an array of records) from the collection, and return them. Each record can be a record instance, an id string or a JS object, any value acceptable as the id argument of collection.get. Fires a &quot;remove&quot; event for each record, and a single &quot;update&quot; event afterwards, unless {silent: true} is passed. The record's index before removal is available to listeners as options.index.</p>
146-
<h4 id="page_collection.reset%28+records%2C+options%3F+%29">collection.reset( records, options? )</h4>
144+
<h3 id="page_collection.reset%28+records%2C+options%3F+%29">collection.reset( records, options? )</h3>
147145
<p>Adding and removing records one at a time is all well and good, but sometimes you have so many records to change that you'd rather just update the collection in bulk. Use reset to replace a collection with a new list of records (or attribute hashes), triggering a single &quot;reset&quot; event on completion, and without triggering any add or remove events on any records. Returns the newly-set records.</p>
148146
<p>Pass null for records to empty your Collection with options.</p>
149147
<p>Here's an example using reset to bootstrap a collection during initial page load, in a Rails application:</p>
@@ -153,7 +151,7 @@ <h4 id="page_collection.reset%28+records%2C+options%3F+%29">collection.reset( re
153151
&lt;/script&gt;
154152
</code></pre>
155153
<p>Calling collection.reset() without passing any records as arguments will empty the entire collection.</p>
156-
<h4 id="page_collection.set%28+records%2C+options%3F+%29">collection.set( records, options? )</h4>
154+
<h3 id="page_collection.set%28+records%2C+options%3F+%29">collection.set( records, options? )</h3>
157155
<p>The set method performs a &quot;smart&quot; update of the collection with the passed list of records. If a record in the list isn't yet in the collection it will be added; if the record is already in the collection its attributes will be merged; and if the collection contains any records that aren't present in the list, they'll be removed. All of the appropriate &quot;add&quot;, &quot;remove&quot;, and &quot;change&quot; events are fired as this happens. Returns the touched records in the collection. If you'd like to customize the behavior, you can disable it with options: {add: false}, {remove: false}, or {merge: false}.</p>
158156
<pre><code class="language-javascript">const vanHalen = new Man.Collection([ eddie, alex, stone, roth ]);
159157

@@ -163,15 +161,15 @@ <h4 id="page_collection.set%28+records%2C+options%3F+%29">collection.set( record
163161
// Updates any of stone, alex, and eddie's attributes that may have
164162
// changed over the years.
165163
</code></pre>
166-
<h4 id="page_collection.get%28+id+%29">collection.get( id )</h4>
164+
<h3 id="page_collection.get%28+id+%29">collection.get( id )</h3>
167165
<p>Get a record from a collection, specified by an <code>id</code>, a <code>cid</code>, or by passing in a record.</p>
168166
<pre><code class="language-javascript">const book = library.get(110);
169167
</code></pre>
170-
<h4 id="page_collection.at%28+index+%29">collection.at( index )</h4>
168+
<h3 id="page_collection.at%28+index+%29">collection.at( index )</h3>
171169
<p>Get a record from a collection, specified by index. Useful if your collection is sorted, and if your collection isn't sorted, at will still retrieve records in insertion order. When passed a negative index, it will retrieve the record from the back of the collection.</p>
172-
<h4 id="page_collection.length">collection.length</h4>
170+
<h3 id="page_collection.length">collection.length</h3>
173171
<p>Like an array, a Collection maintains a length property, counting the number of models it contains.</p>
174-
<h4 id="page_collection.models">collection.models</h4>
172+
<h3 id="page_collection.models">collection.models</h3>
175173
<p>Raw access to the JavaScript array of models inside of the collection. Usually you'll want to use <code>get</code>, <code>at</code>, or the other methods to access model objects, but occasionally a direct reference to the array is desired.</p>
176174
</div>
177175

docs/Collection/Proxied_array_methods.html

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,24 @@
7676

7777
<div class="Page__header">
7878
<h1>Proxied array methods</h1>
79-
<span style="float: left; font-size: 10px; color: gray;">
80-
Saturday, May 20, 2017 3:49 PM </span>
8179
<span style="float: right; font-size: 10px; color: gray;">
8280
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/01_Proxied_array_methods.md" target="_blank">Edit on GitHub</a>
8381
</span>
8482
</div>
8583

8684

8785
<div class="s-content">
88-
<h4 id="page_collection.push%28+record%2C+options%3F+%29">collection.push( record, options? )</h4>
86+
<h3 id="page_collection.push%28+record%2C+options%3F+%29">collection.push( record, options? )</h3>
8987
<p>Add a record at the end of a collection. Takes the same options as add.</p>
90-
<h4 id="page_collection.pop%28+options%3F+%29">collection.pop( options? )</h4>
88+
<h3 id="page_collection.pop%28+options%3F+%29">collection.pop( options? )</h3>
9189
<p>Remove and return the last record from a collection. Takes the same options as remove.</p>
92-
<h4 id="page_collection.unshift%28+model%2C+options%3F+%29">collection.unshift( model, options? )</h4>
90+
<h3 id="page_collection.unshift%28+model%2C+options%3F+%29">collection.unshift( model, options? )</h3>
9391
<p>Add a model at the beginning of a collection. Takes the same options as add.</p>
94-
<h4 id="page_collection.shift%28+options%3F+%29">collection.shift( options? )</h4>
92+
<h3 id="page_collection.shift%28+options%3F+%29">collection.shift( options? )</h3>
9593
<p>Remove and return the first model from a collection. Takes the same options as remove.</p>
96-
<h4 id="page_collection.slice%28+begin%2C+end+%29">collection.slice( begin, end )</h4>
94+
<h3 id="page_collection.slice%28+begin%2C+end+%29">collection.slice( begin, end )</h3>
9795
<p>Return a shallow copy of the <code>collection.models</code>, using the same options as native Array#slice.</p>
98-
<h4 id="page_collection.indexOf%28+recordOrId+%3A+any+%29+%3A+number">collection.indexOf( recordOrId : any ) : number</h4>
96+
<h3 id="page_collection.indexOf%28+recordOrId+%3A+any+%29+%3A+number">collection.indexOf( recordOrId : any ) : number</h3>
9997
<p>Return an index of the record in the collection, and -1 if there are no such a record in the collection.</p>
10098
<p>Can take the record itself as an argument, <code>id</code>, or <code>cid</code> of the record.</p>
10199
</div>

docs/Collection/Serialization.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,18 @@
7676

7777
<div class="Page__header">
7878
<h1>Serialization</h1>
79-
<span style="float: left; font-size: 10px; color: gray;">
80-
Saturday, May 20, 2017 3:49 PM </span>
8179
<span style="float: right; font-size: 10px; color: gray;">
8280
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/Serialization.md" target="_blank">Edit on GitHub</a>
8381
</span>
8482
</div>
8583

8684

8785
<div class="s-content">
88-
<h2 id="page_Serialization+methods">Serialization methods</h2>
89-
<h4 id="page_colleciton.parse%28+json+%29">colleciton.parse( json )</h4>
86+
<h1 id="page_Serialization+methods">Serialization methods</h1>
87+
<h3 id="page_colleciton.parse%28+json+%29">colleciton.parse( json )</h3>
9088
<p>Called when <code>{ parse : true }</code> option is used in collection's <code>constructor</code>, <code>set</code>, <code>reset</code>, and <code>add</code> methods.</p>
9189
<p>May be overriden to transforms the responce from the server.</p>
92-
<h4 id="page_collection.toJSON%28%29">collection.toJSON()</h4>
90+
<h3 id="page_collection.toJSON%28%29">collection.toJSON()</h3>
9391
<p>Return an array containing the attributes hash of each model (via toJSON) in the collection. This can be used to serialize and persist the collection as a whole. The name of this method is a bit confusing, because it conforms to JavaScript's JSON API.</p>
9492
<pre><code class="language-javascript">@define class Man extends Record {
9593
static attributes = {
@@ -106,7 +104,7 @@ <h4 id="page_collection.toJSON%28%29">collection.toJSON()</h4>
106104

107105
alert(JSON.stringify(collection));
108106
</code></pre>
109-
<h2 id="page_Polymorphic+collections">Polymorphic collections</h2>
107+
<h1 id="page_Polymorphic+collections">Polymorphic collections</h1>
110108
<p>Collection may contain polimorphic records of different types if they are the subclass of the <code>model</code>.
111109
You need to define static <code>Model.create</code> factory method to make an abstract model serializable.</p>
112110
<pre><code class="language-javascript">@define // Serializable abstract Record

docs/Collection/Sorted_collections.html

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@
7676

7777
<div class="Page__header">
7878
<h1>Sorted collections</h1>
79-
<span style="float: left; font-size: 10px; color: gray;">
80-
Saturday, May 20, 2017 3:49 PM </span>
8179
<span style="float: right; font-size: 10px; color: gray;">
8280
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/03_Sorted_collections.md" target="_blank">Edit on GitHub</a>
8381
</span>
@@ -88,11 +86,11 @@ <h1>Sorted collections</h1>
8886
<p>By default there is no comparator for a collection. If you define a comparator, it will be used to maintain the collection in sorted order. This means that as records are added, they are inserted at the correct index in collection.models.</p>
8987
<p>Note that Type-R depends on the arity of your comparator function to determine between the two styles, so be careful if your comparator function is bound.</p>
9088
<p>Collections with a comparator will not automatically re-sort if you later change model attributes, so you may wish to call sort after changing model attributes that would affect the order.</p>
91-
<h4 id="page_comparator+%3D+%27attrName%27"><code>static</code> comparator = 'attrName'</h4>
89+
<h3 id="page_comparator+%3D+%27attrName%27"><code>static</code> comparator = 'attrName'</h3>
9290
<p>Maintain the collection in sorted order by the given record's attribute.</p>
93-
<h4 id="page_comparator+%3D+x+%3D%3E+number+%7C+string"><code>static</code> comparator = x =&gt; number | string</h4>
91+
<h3 id="page_comparator+%3D+x+%3D%3E+number+%7C+string"><code>static</code> comparator = x =&gt; number | string</h3>
9492
<p>&quot;sortBy&quot; comparator functions take a model and return a numeric or string value by which the model should be ordered relative to others.</p>
95-
<h4 id="page_comparator+%3D+%28+x%2C+y+%29+%3D%3E+-1+%7C+0+%7C+1"><code>static</code> comparator = ( x, y ) =&gt; -1 | 0 | 1</h4>
93+
<h3 id="page_comparator+%3D+%28+x%2C+y+%29+%3D%3E+-1+%7C+0+%7C+1"><code>static</code> comparator = ( x, y ) =&gt; -1 | 0 | 1</h3>
9694
<p>&quot;sort&quot; comparator functions take two models, and return -1 if the first model should come before the second, 0 if they are of the same rank and 1 if the first model should come after.</p>
9795
<p>Note how even though all of the chapters in this example are added backwards, they come out in the proper order:</p>
9896
<pre><code class="language-javascript">var Chapter = Backbone.Model;
@@ -106,7 +104,7 @@ <h4 id="page_comparator+%3D+%28+x%2C+y+%29+%3D%3E+-1+%7C+0+%7C+1"><code>static</
106104

107105
alert(chapters.pluck('title'));
108106
</code></pre>
109-
<h4 id="page_collection.sort%28+options%3F+%29">collection.sort( options? )</h4>
107+
<h3 id="page_collection.sort%28+options%3F+%29">collection.sort( options? )</h3>
110108
<p>Force a collection to re-sort itself. You don't need to call this under normal circumstances, as a collection with a comparator will sort itself whenever a model is added. To disable sorting when adding a model, pass <code>{sort: false}</code> to add. Calling sort triggers a &quot;sort&quot; event on the collection.</p>
111109
</div>
112110

0 commit comments

Comments
 (0)