Skip to content

Commit 12e300a

Browse files
author
Vlad Balin
committed
docs update
1 parent ad4b06b commit 12e300a

34 files changed

+1220
-129
lines changed
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
<!DOCTYPE html>
2+
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
3+
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
4+
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
5+
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
6+
<head>
7+
<title>Events and transactions - Type-R</title>
8+
<meta name="description" content="Universal state management framework" />
9+
<meta name="author" content="Vlad Balin">
10+
<meta charset="UTF-8">
11+
<link rel="icon" href="../themes/daux/img/favicon-navy.png" type="image/x-icon">
12+
<!-- Mobile -->
13+
<meta name="apple-mobile-web-app-capable" content="yes" />
14+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
15+
16+
<!-- Font -->
17+
<link href='https://fonts.googleapis.com/css?family=Roboto+Slab:400,100,300,700&subset=latin,cyrillic-ext,cyrillic' rel='stylesheet' type='text/css'>
18+
<!-- CSS -->
19+
<link href='../themes/daux/css/theme-navy.min.css' rel='stylesheet' type='text/css'>
20+
<!-- Tipue Search -->
21+
<link href="../tipuesearch/tipuesearch.css" rel="stylesheet">
22+
23+
<!--[if lt IE 9]>
24+
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
25+
<![endif]-->
26+
</head>
27+
<body class="">
28+
29+
<header class="Navbar hidden-print">
30+
<a class="Navbar__brand" href="../index.html">Type-R</a>
31+
32+
<div class="Search">
33+
<svg class="Search__icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 451 451"><path d="M447.05 428l-109.6-109.6c29.4-33.8 47.2-77.9 47.2-126.1C384.65 86.2 298.35 0 192.35 0 86.25 0 .05 86.3.05 192.3s86.3 192.3 192.3 192.3c48.2 0 92.3-17.8 126.1-47.2L428.05 447c2.6 2.6 6.1 4 9.5 4s6.9-1.3 9.5-4c5.2-5.2 5.2-13.8 0-19zM26.95 192.3c0-91.2 74.2-165.3 165.3-165.3 91.2 0 165.3 74.2 165.3 165.3s-74.1 165.4-165.3 165.4c-91.1 0-165.3-74.2-165.3-165.4z"/></svg>
34+
<input type="search" id="tipue_search_input" class="Search__field" placeholder="Search..." autocomplete="on" results=25 autosave=text_search>
35+
</div>
36+
</header>
37+
<div class="Columns content">
38+
<aside class="Columns__left Collapsible">
39+
<div class="Collapsible__container">
40+
<button type="button" class="Button Collapsible__trigger">
41+
<span class="Collapsible__trigger--bar"></span>
42+
<span class="Collapsible__trigger--bar"></span>
43+
<span class="Collapsible__trigger--bar"></span>
44+
</button>
45+
</div>
46+
47+
<div class="Collapsible__content">
48+
<!-- Navigation -->
49+
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li><li class='Nav__item '><a href="../Overview.html">Overview</a></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item has-children'><a href="../Record/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Record/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../Record/Events_and_Transactions.html">Events and Transactions</a></li><li class='Nav__item '><a href="../Record/Validation.html">Validation</a></li><li class='Nav__item '><a href="../Record/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Record/id_ and_id-references.html">id and id-references</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../Collection/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item '><a href="../Collection/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Collection/Proxied_array_methods.html">Proxied array methods</a></li><li class='Nav__item '><a href="../Collection/Iteration_methods.html">Iteration methods</a></li><li class='Nav__item '><a href="../Collection/Sorted_collections.html">Sorted collections</a></li><li class='Nav__item Nav__item--active'><a href="../Collection/Events_and_transactions.html">Events and transactions</a></li><li class='Nav__item '><a href="../Collection/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Collection/Validation.html">Validation</a></li></ul></li></ul>
50+
51+
<div class="Links">
52+
<hr/>
53+
<a href="https://github.com/Volicon/React-MVx/issues" target="_blank">Help/Support/Bugs</a>
54+
<br />
55+
<a href="http://volicon.com" target="_blank">Made by Volicon (a Verizon company)</a>
56+
<br />
57+
58+
<div class="CodeToggler">
59+
<hr/>
60+
<a class="CodeToggler__button CodeToggler__button--main" href="#">Show Code Blocks Inline</a><br>
61+
</div>
62+
63+
<hr/>
64+
<div class="Twitter">
65+
<iframe allowtransparency="true" frameborder="0" scrolling="no" style="width:162px; height:20px;" src="https://platform.twitter.com/widgets/follow_button.html?screen_name=gaperton&amp;show_count=false"></iframe>
66+
<br />
67+
<br />
68+
</div>
69+
</div>
70+
</div>
71+
</aside>
72+
<div class="Columns__right ">
73+
<div class="Columns__right__content">
74+
<div class="doc_content">
75+
<article class="Page">
76+
77+
<div class="Page__header">
78+
<h1>Events and transactions</h1>
79+
<span style="float: left; font-size: 10px; color: gray;">
80+
Thursday, May 18, 2017 11:37 AM </span>
81+
<span style="float: right; font-size: 10px; color: gray;">
82+
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/Events_and_transactions.md" target="_blank">Edit on GitHub</a>
83+
</span>
84+
</div>
85+
86+
87+
<div class="s-content">
88+
<h2 id="page_How+collection+updates+are+processed">How collection updates are processed</h2>
89+
<p>All updates to the collections are executed in the scope of transactions, which are executed in 4 steps:</p>
90+
<ol>
91+
<li>Apply all changes to collection and nested records.</li>
92+
<li>Trigger <code>add</code>, <code>remove</code>, or <code>change</code> event for every individual record change.</li>
93+
<li>Trigger an <code>update</code> event when there are any records added or removed, and <code>sort</code> event if an order of records was changed.</li>
94+
<li>If any changes were applied to the collection:
95+
<ul>
96+
<li>trigger <code>changes</code> event;</li>
97+
<li>notify collection's owner on aggregation subtree changes.</li>
98+
</ul>
99+
</li>
100+
</ol>
101+
<p>Every collection update method opens an implicit transaction.</p>
102+
<h4 id="page_record.transaction%28+fun+%29">record.transaction( fun )</h4>
103+
<p>Execute the sequence of updates in <code>fun</code> function in the scope of the transaction, so it will trigger the single <code>change</code> event.</p>
104+
<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>
105+
<p>Similar to the <code>collection.each</code>, but wraps an iteration in a transaction.</p>
106+
<h2 id="page_Listening+to+change+events">Listening to change events</h2>
107+
<p>TODO (Events API)</p>
108+
<h4 id="page_itemEvents+%3D+%7B+eventName+%3A++%2C+...+%7D"><code>static</code> itemEvents = { eventName : <code>handler</code>, ... }</h4>
109+
<p>Subscribe for events from records. The <code>hander</code> is either the collection's method name, the handler function, or <code>true</code>.</p>
110+
<p>When <code>true</code> is passed as a handler, the corresponding event will be triggered on the collection.</p>
111+
</div>
112+
113+
<nav>
114+
<ul class="Pager">
115+
<li class=Pager--prev><a href="../Collection/Sorted_collections.html">Previous</a></li> <li class=Pager--next><a href="../Collection/Serialization.html">Next</a></li> </ul>
116+
</nav>
117+
</article>
118+
119+
</div>
120+
</div>
121+
</div>
122+
</div>
123+
124+
125+
<!-- jQuery -->
126+
<script src="../themes/daux/js/jquery-1.11.3.min.js"></script>
127+
128+
<!-- hightlight.js -->
129+
<script src="../themes/daux/js/highlight.pack.js"></script>
130+
<script>hljs.initHighlightingOnLoad();</script>
131+
132+
<!-- JS -->
133+
134+
<script src="../themes/daux/js/daux.js"></script>
135+
136+
<!-- Tipue Search -->
137+
<script type="text/javascript" src="../tipuesearch/tipuesearch.js"></script>
138+
139+
<script>
140+
window.onunload = function(){}; // force $(document).ready to be called on back/forward navigation in firefox
141+
$(function() {
142+
tipuesearch({
143+
'base_url': '../'
144+
});
145+
});
146+
</script>
147+
148+
</body>
149+
</html>

docs/Collection/Iteration_methods.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
<div class="Collapsible__content">
4848
<!-- Navigation -->
49-
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item '><a href="../Overview.html">Overview</a></li><li class='Nav__item has-children'><a href="../Record/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Record/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../Record/Transactions_and_Events.html">Transactions and Events</a></li><li class='Nav__item '><a href="../Record/Validation.html">Validation</a></li><li class='Nav__item '><a href="../Record/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Record/id_ and_id-references.html">id and id-references</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../Collection/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item '><a href="../Collection/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Collection/Proxied_array_methods.html">Proxied array methods</a></li><li class='Nav__item Nav__item--active'><a href="../Collection/Iteration_methods.html">Iteration methods</a></li><li class='Nav__item '><a href="../Collection/Sorted_collections.html">Sorted collections</a></li></ul></li></ul>
49+
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li><li class='Nav__item '><a href="../Overview.html">Overview</a></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item has-children'><a href="../Record/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Record/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../Record/Events_and_Transactions.html">Events and Transactions</a></li><li class='Nav__item '><a href="../Record/Validation.html">Validation</a></li><li class='Nav__item '><a href="../Record/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Record/id_ and_id-references.html">id and id-references</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../Collection/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item '><a href="../Collection/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Collection/Proxied_array_methods.html">Proxied array methods</a></li><li class='Nav__item Nav__item--active'><a href="../Collection/Iteration_methods.html">Iteration methods</a></li><li class='Nav__item '><a href="../Collection/Sorted_collections.html">Sorted collections</a></li><li class='Nav__item '><a href="../Collection/Events_and_transactions.html">Events and transactions</a></li><li class='Nav__item '><a href="../Collection/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Collection/Validation.html">Validation</a></li></ul></li></ul>
5050

5151
<div class="Links">
5252
<hr/>

docs/Collection/Overview.html

Lines changed: 2 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646

4747
<div class="Collapsible__content">
4848
<!-- Navigation -->
49-
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item '><a href="../Overview.html">Overview</a></li><li class='Nav__item has-children'><a href="../Record/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Record/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../Record/Transactions_and_Events.html">Transactions and Events</a></li><li class='Nav__item '><a href="../Record/Validation.html">Validation</a></li><li class='Nav__item '><a href="../Record/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Record/id_ and_id-references.html">id and id-references</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../Collection/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item Nav__item--active'><a href="../Collection/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Collection/Proxied_array_methods.html">Proxied array methods</a></li><li class='Nav__item '><a href="../Collection/Iteration_methods.html">Iteration methods</a></li><li class='Nav__item '><a href="../Collection/Sorted_collections.html">Sorted collections</a></li></ul></li></ul>
49+
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li><li class='Nav__item '><a href="../Overview.html">Overview</a></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item has-children'><a href="../Record/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Record/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../Record/Events_and_Transactions.html">Events and Transactions</a></li><li class='Nav__item '><a href="../Record/Validation.html">Validation</a></li><li class='Nav__item '><a href="../Record/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Record/id_ and_id-references.html">id and id-references</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../Collection/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item Nav__item--active'><a href="../Collection/Overview.html">Overview</a></li><li class='Nav__item '><a href="../Collection/Proxied_array_methods.html">Proxied array methods</a></li><li class='Nav__item '><a href="../Collection/Iteration_methods.html">Iteration methods</a></li><li class='Nav__item '><a href="../Collection/Sorted_collections.html">Sorted collections</a></li><li class='Nav__item '><a href="../Collection/Events_and_transactions.html">Events and transactions</a></li><li class='Nav__item '><a href="../Collection/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Collection/Validation.html">Validation</a></li></ul></li></ul>
5050

5151
<div class="Links">
5252
<hr/>
@@ -77,7 +77,7 @@
7777
<div class="Page__header">
7878
<h1>Overview</h1>
7979
<span style="float: left; font-size: 10px; color: gray;">
80-
Thursday, May 18, 2017 9:30 AM </span>
80+
Thursday, May 18, 2017 11:13 AM </span>
8181
<span style="float: right; font-size: 10px; color: gray;">
8282
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/05_Collection/00_Overview.md" target="_blank">Edit on GitHub</a>
8383
</span>
@@ -120,43 +120,6 @@ <h4 id="page_model+%3D+RecordConstructor"><code>static</code> model = RecordCons
120120
</code></pre>
121121
<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>
122122
<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-
<h3 id="page_Polymorphic+collections">Polymorphic collections</h3>
124-
<p>Collection may contain polimorphic records of different types if they are the subclass of the <code>model</code>.
125-
You need to define static <code>Model.create</code> method to make an abstract model serializable.</p>
126-
<pre><code class="language-javascript">@define // Serializable abstract Record
127-
class Document extends Record {
128-
static attrbutes = {
129-
type : String,
130-
// attrs definition...
131-
};
132-
133-
// Factory method needs to be defined.
134-
static create( attrs, options ){
135-
switch( attrs.type ){
136-
case &quot;public&quot; : return new PublicDocument( attrs, options );
137-
case &quot;private&quot; : return new PrivateDocument( attrs, options );
138-
}
139-
}
140-
}
141-
142-
const Library = Document.Collection;
143-
144-
@define
145-
class PublicDocument extends Document {
146-
static attributes = {
147-
type : 'public',
148-
// attrs definition...
149-
}
150-
}
151-
152-
@define
153-
class PrivateDocument extends Document {
154-
static attributes = {
155-
type : 'private',
156-
// attrs definition...
157-
}
158-
}
159-
</code></pre>
160123
<h2 id="page_Members">Members</h2>
161124
<h4 id="page_constructor%28+models%3F%2C+options%3F+%29">constructor( models?, options? )</h4>
162125
<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.

0 commit comments

Comments
 (0)