Skip to content

Commit 950e0e6

Browse files
author
Vlad Balin
committed
Merge branch 'f/separation-of-concerns-docs'
2 parents c20c799 + 73259ee commit 950e0e6

File tree

97 files changed

+1218
-5990
lines changed

Some content is hidden

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

97 files changed

+1218
-5990
lines changed
Lines changed: 9 additions & 26 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="../General_concepts/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>General concepts</a><ul class='Nav'><li class='Nav__item '><a href="../General_concepts/Overview.html">Overview</a></li><li class='Nav__item '><a href="../General_concepts/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../General_concepts/Updates_and_change_events.html">Updates and change events</a></li><li class='Nav__item '><a href="../General_concepts/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../General_concepts/Validation.html">Validation</a></li></ul></li><li class='Nav__item Nav__item--open 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 Nav__item--active'><a href="../Record/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../Record/Updates_and_change_events.html">Updates and change 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 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 '><a href="../Collection/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Collection/Updates_and_Events.html">Updates and Events</a></li><li class='Nav__item '><a href="../Collection/Validation.html">Validation</a></li></ul></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li></ul>
49+
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item has-children'><a href="../Record/Definition.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Definition.html">Definition</a></li><li class='Nav__item '><a href="../Record/Updates_and_transactions.html">Updates and transactions</a></li><li class='Nav__item '><a href="../Record/Listening_to_events.html">Listening to events</a></li></ul></li><li class='Nav__item has-children'><a href="../Collection/Definition.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item '><a href="../Collection/Definition.html">Definition</a></li><li class='Nav__item '><a href="../Collection/Updates_and_transactions.html">Updates and transactions</a></li><li class='Nav__item '><a href="../Collection/Listening_to_events.html">Listening to events</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/Proxied_array_methods.html">Proxied array methods</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../API_by_feature/Aggregation_tree.html" class="folder"><i class="Nav__arrow">&nbsp;</i>API by feature</a><ul class='Nav'><li class='Nav__item Nav__item--active'><a href="../API_by_feature/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../API_by_feature/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../API_by_feature/Validation.html">Validation</a></li><li class='Nav__item '><a href="../API_by_feature/Shared_objects.html">Shared objects</a></li><li class='Nav__item '><a href="../API_by_feature/id-references.html">id-references</a></li><li class='Nav__item '><a href="../API_by_feature/Stores.html">Stores</a></li></ul></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li></ul>
5050

5151
<div class="Links">
5252
<hr/>
@@ -77,7 +77,7 @@
7777
<div class="Page__header">
7878
<h1>Aggregation tree</h1>
7979
<span style="float: right; font-size: 10px; color: gray;">
80-
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/04_Record/02_Aggregation_tree.md" target="_blank">Edit on GitHub</a>
80+
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/06_API_by_feature/01_Aggregation_tree.md" target="_blank">Edit on GitHub</a>
8181
</span>
8282
</div>
8383

@@ -109,44 +109,27 @@ <h1>Aggregation tree</h1>
109109
<li>They are validated as part of the record.</li>
110110
<li>They are serialized as nested JSON.</li>
111111
</ul>
112-
<h1 id="page_Declarations">Declarations</h1>
113-
<h3 id="page_attr+%3A+Type.shared"><code>attrDef</code> attr : Type.shared</h3>
114-
<p>Attributes can be marked as <em>shared</em> with adding <code>Type.shared</code> modifier. Such an attribute is not the member of record's aggregation/ownership tree.</p>
115-
<ul>
116-
<li>It's initialized with <code>null</code>
117-
</li>
118-
<li>It's not cloned when the record is cloned (just the reference is copied over).</li>
119-
<li>It's not disposed when the record is disposed.</li>
120-
<li>It's not validated as part of the record (always valid by default)</li>
121-
<li>It's excluded from serialization.</li>
122-
</ul>
123-
<pre><code class="language-javascript">@define class UsersListState extends Record {
124-
static attributes = {
125-
users : User.Collection,
126-
selected : User.shared // can be assigned with the user from this.users
127-
}
128-
}
129-
</code></pre>
130-
<h1 id="page_Class+methods">Class methods</h1>
131-
<h3 id="page_record.getOwner%28%29">record.getOwner()</h3>
112+
<h1 id="page_Aggregation+tree+methods">Aggregation tree methods</h1>
113+
<h3 id="page_recordOrCollection.getOwner%28%29">recordOrCollection.getOwner()</h3>
132114
<p>Return the reference to the record's owner, or <code>null</code> if record is not the part of aggregation tree.</p>
133-
<p>Due to the nature of <em>aggregation</em>, record may have one and only one owner.</p>
134-
<h3 id="page_record.clone%28%29">record.clone()</h3>
115+
<p>Due to the nature of <em>aggregation</em>, an object may have one and only one owner.</p>
116+
<h3 id="page_recordOrCollection.clone%28%29">recordOrCollection.clone()</h3>
135117
<p>Clone the record and all aggregated records and collections.</p>
136118
<p>The whole aggregation tree will be recursively cloned, references to shared members will copied.</p>
137119
<h3 id="page_record.assignFrom%28+otherRecord+%29">record.assignFrom( otherRecord )</h3>
120+
<h3 id="page_collection.assignFrom%28+otherCollection+%29">collection.assignFrom( otherCollection )</h3>
138121
<p>Recursively assign the record and its aggregated members with values from <code>otherRecord</code>.
139122
This operation is similar to <code>record.clone()</code>, but instead of <em>creation</em> of the cloned record it makes an <em>existing</em> record to be the copy
140123
of other record.</p>
141124
<p>The whole aggregation tree will be recursively assigned, references to shared members will copied.</p>
142-
<h3 id="page_record.dispose%28%29">record.dispose()</h3>
125+
<h3 id="page_recordOrCollection.dispose%28%29">recordOrCollection.dispose()</h3>
143126
<p>Recursively dispose the record and its aggregated members. &quot;Dispose&quot; means that elements of the aggregation tree will unsubscribe from all event sources. It's crucial to prevent memory leaks in SPA.</p>
144127
<p>The whole aggregation tree will be recursively disposed, shared members won't.</p>
145128
</div>
146129

147130
<nav>
148131
<ul class="Pager">
149-
<li class=Pager--prev><a href="../Record/Overview.html">Previous</a></li> <li class=Pager--next><a href="../Record/Updates_and_change_events.html">Next</a></li> </ul>
132+
<li class=Pager--prev><a href="../Collection/Proxied_array_methods.html">Previous</a></li> <li class=Pager--next><a href="../API_by_feature/Serialization.html">Next</a></li> </ul>
150133
</nav>
151134
</article>
152135

Lines changed: 18 additions & 36 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="../General_concepts/Overview.html" class="folder"><i class="Nav__arrow">&nbsp;</i>General concepts</a><ul class='Nav'><li class='Nav__item '><a href="../General_concepts/Overview.html">Overview</a></li><li class='Nav__item '><a href="../General_concepts/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item '><a href="../General_concepts/Updates_and_change_events.html">Updates and change events</a></li><li class='Nav__item '><a href="../General_concepts/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../General_concepts/Validation.html">Validation</a></li></ul></li><li class='Nav__item Nav__item--open 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/Updates_and_change_events.html">Updates and change events</a></li><li class='Nav__item '><a href="../Record/Validation.html">Validation</a></li><li class='Nav__item Nav__item--active'><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 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 '><a href="../Collection/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../Collection/Updates_and_Events.html">Updates and Events</a></li><li class='Nav__item '><a href="../Collection/Validation.html">Validation</a></li></ul></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li></ul>
49+
<ul class='Nav'><li class='Nav__item '><a href="../Getting_Started.html">Getting Started</a></li><li class='Nav__item has-children'><a href="../Record/Definition.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Record</a><ul class='Nav'><li class='Nav__item '><a href="../Record/Definition.html">Definition</a></li><li class='Nav__item '><a href="../Record/Updates_and_transactions.html">Updates and transactions</a></li><li class='Nav__item '><a href="../Record/Listening_to_events.html">Listening to events</a></li></ul></li><li class='Nav__item has-children'><a href="../Collection/Definition.html" class="folder"><i class="Nav__arrow">&nbsp;</i>Collection</a><ul class='Nav'><li class='Nav__item '><a href="../Collection/Definition.html">Definition</a></li><li class='Nav__item '><a href="../Collection/Updates_and_transactions.html">Updates and transactions</a></li><li class='Nav__item '><a href="../Collection/Listening_to_events.html">Listening to events</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/Proxied_array_methods.html">Proxied array methods</a></li></ul></li><li class='Nav__item Nav__item--open has-children'><a href="../API_by_feature/Aggregation_tree.html" class="folder"><i class="Nav__arrow">&nbsp;</i>API by feature</a><ul class='Nav'><li class='Nav__item '><a href="../API_by_feature/Aggregation_tree.html">Aggregation tree</a></li><li class='Nav__item Nav__item--active'><a href="../API_by_feature/Serialization.html">Serialization</a></li><li class='Nav__item '><a href="../API_by_feature/Validation.html">Validation</a></li><li class='Nav__item '><a href="../API_by_feature/Shared_objects.html">Shared objects</a></li><li class='Nav__item '><a href="../API_by_feature/id-references.html">id-references</a></li><li class='Nav__item '><a href="../API_by_feature/Stores.html">Stores</a></li></ul></li><li class='Nav__item '><a href="../Events.html">Events</a></li><li class='Nav__item '><a href="../Mixins.html">Mixins</a></li></ul>
5050

5151
<div class="Links">
5252
<hr/>
@@ -77,53 +77,35 @@
7777
<div class="Page__header">
7878
<h1>Serialization</h1>
7979
<span style="float: right; font-size: 10px; color: gray;">
80-
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/04_Record/05_Serialization.md" target="_blank">Edit on GitHub</a>
80+
<a href="https://github.com/Volicon/React-MVx/blob/develop/docs/06_API_by_feature/02_Serialization.md" target="_blank">Edit on GitHub</a>
8181
</span>
8282
</div>
8383

8484

8585
<div class="s-content">
86-
<h1 id="page_Declarations">Declarations</h1>
86+
<p>Aggregation tree formed of records and collections is serializable by default. Record corresponds to an object in JSON, while the collection is represented as an array.</p>
87+
<h2 id="page_Serialization+API">Serialization API</h2>
88+
<h3 id="page_recordOrCollection.toJSON%28%29">recordOrCollection.toJSON()</h3>
89+
<p>Produces the JSON for the aggregation tree of the record or collection. May be overriden in particular record or collection.</p>
90+
<h3 id="page_new+RecordOrCollection%28+json%2C+%7B+parse+%3A+true+%7D+%29">new RecordOrCollection( json, { parse : true } )</h3>
91+
<p>Constructs an aggregation tree from its JSON representation.</p>
92+
<h3 id="page_recordOrCollection.set%28+json%2C+%7B+parse+%3A+true+%7D+%29">recordOrCollection.set( json, { parse : true } )</h3>
93+
<p>Update an aggregation tree from its JSON representation.</p>
94+
<h3 id="page_recordOrCollection.parse%28+json+%29">recordOrCollection.parse( json )</h3>
95+
<p>May be overriden to add custom JSON transformation.</p>
96+
<h2 id="page_Attribute-level+serialization+control">Attribute-level serialization control</h2>
97+
<p>Serialization can be controlled for the specific attribute in the Recrod's attribute definition.</p>
8798
<h3 id="page_attr+%3A+Type.has.toJSON%28+false+%29"><code>attrDef</code> attr : Type.has.toJSON( false )</h3>
88-
<p>Exclude attribute from serialization.</p>
99+
<p>Exclude attribute from the resulting JSON.</p>
89100
<h3 id="page_attr+%3A+Type.has.toJSON%28+%28+value%2C+name+%29+%3D%3E+json+%29"><code>attrDef</code> attr : Type.has.toJSON( ( value, name ) =&gt; json )</h3>
90101
<p>Override the default toJSON() method for the selected record's attribute.</p>
91-
<h3 id="page_attr+%3A+Type.has.parse%28%29"><code>attrDef</code> attr : Type.has.parse()</h3>
92-
<p>Transform the data before it will be passed to the record's attribute when <code>{ parse : true }</code> option is used.</p>
93-
<h1 id="page_Class+members">Class members</h1>
94-
<h3 id="page_record.parse%28+json+%29">record.parse( json )</h3>
95-
<p>May be overriden to transform constructor or <code>set</code> argument when <code>{ parse : true }</code> option is used.</p>
96-
<h3 id="page_constructor%28+json%2C+%7B+parse+%3A+true+%7D+%29">constructor( json, { parse : true } )</h3>
97-
<p>Call <code>record.parse( json )</code> and attribute-level parse transforms. They won't be executed by default.</p>
98-
<h3 id="page_record.set%28+json%2C+%7B+parse+%3A+true+%7D+%29">record.set( json, { parse : true } )</h3>
99-
<p>Call <code>record.parse( json )</code> and attribute-level parse transforms. They won't be executed by default.</p>
100-
<h3 id="page_record.toJSON%28%29">record.toJSON()</h3>
101-
<p>Create record's JSON representation. This can be used for persistence, serialization, or for augmentation before being sent to the server.
102-
The name of this method is a bit confusing, as it doesn't actually return a JSON string — but I'm afraid that it's the way that the JavaScript API for JSON.stringify works.</p>
103-
<pre><code class="language-javascript">@define class Artist extends Record {
104-
static attributes = {
105-
firstName: String,
106-
lastName: String,
107-
birthday : Date,
108-
code : String.has.toJSON( x =&gt; x.toLowerCase() )
109-
}
110-
}
111-
112-
const artist = new Artist({
113-
firstName: &quot;Wassily&quot;,
114-
lastName: &quot;Kandinsky&quot;
115-
});
116-
117-
artist.birthday = new Date( 1866, 12, 16 );
118-
119-
alert( JSON.stringify( artist ) );
120-
</code></pre>
121-
<p>It will, however, produce correct JSON for all the complex attribute types.</p>
102+
<h3 id="page_attr+%3A+Type.has.parse%28+%28+json%2C+name+%29+%3D%3E+value+%29"><code>attrDef</code> attr : Type.has.parse( ( json, name ) =&gt; value )</h3>
103+
<p>Transform the data before it will be passed to the record's attribute.</p>
122104
</div>
123105

124106
<nav>
125107
<ul class="Pager">
126-
<li class=Pager--prev><a href="../Record/Validation.html">Previous</a></li> <li class=Pager--next><a href="../Record/id_ and_id-references.html">Next</a></li> </ul>
108+
<li class=Pager--prev><a href="../API_by_feature/Aggregation_tree.html">Previous</a></li> <li class=Pager--next><a href="../API_by_feature/Validation.html">Next</a></li> </ul>
127109
</nav>
128110
</article>
129111

0 commit comments

Comments
 (0)