Skip to content

Commit 5c2f036

Browse files
authored
feat: Add reactive systems to the Ecsact language page (#140)
1 parent 38be492 commit 5c2f036

File tree

1 file changed

+62
-1
lines changed

1 file changed

+62
-1
lines changed

src/app/docs/lang/lang.component.html

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,69 @@ <h3 id="lazy-systems">Lazy Systems</h3>
306306
{{'}'}}
307307
</code></pre>
308308

309+
<h3 id="reactive-systems">Reactive Systems</h3>
310+
<p>
311+
You can set a system to only run under certain conditions per component.
312+
</p>
313+
<h4 id="reactive-keywords">Keywords</h4>
314+
<table>
315+
<tr>
316+
<th>Keyword</th>
317+
<th>Description</th>
318+
</tr>
319+
<tr>
320+
<td><code>oninit</code></td>
321+
<td>System runs when component is initialized on qualifying entity.</td>
322+
</tr>
323+
<tr>
324+
<td><code>onupdate</code></td>
325+
<td>System runs when component is updated on qualifying entity.</td>
326+
</tr>
327+
<tr>
328+
<td><code>onremove</code></td>
329+
<td>
330+
System runs once when component is removed, even though the entity no
331+
longer qualifies for the system.
332+
</td>
333+
</tr>
334+
<tr>
335+
<td><code>onchange</code></td>
336+
<td>
337+
System runs when component is updated and one or more of its values have
338+
changed.
339+
</td>
340+
</tr>
341+
</table>
342+
343+
<h4 id="reactive-syntax">Syntax</h4>
344+
<p>
345+
The notify keyword is put in the body of a system and can be applied to all
346+
components or a selective list of components:
347+
</p>
348+
<pre><code ecsactLangSyntax>
349+
system BasicNotifySystem {{'{'}}
350+
readwrite ExampleComponentA;
351+
readwrite ExampleComponentB;
352+
353+
// You can specify notify without a body and apply to all components
354+
notify oninit;
355+
{{'}'}}
356+
357+
system MixedNotifySystem {{'{'}}
358+
readwrite ExampleComponentA;
359+
readwrite ExampleComponentB;
360+
readwrite NoNotifiesComponent;
361+
362+
// You can give notify a body to specialize for each component
363+
notify {{'{'}}
364+
oninit ExampleComponentA;
365+
onchange ExampleComponentB;
366+
{{'}'}}
367+
{{'}'}}
368+
</code></pre>
369+
309370
<h2 id="fields">Fields</h2>
310-
<p>Both components and actions may contain any number of fields</p>
371+
<p>Both components and actions may contain any number of fields.</p>
311372
<h3 id="field-types">Field Types</h3>
312373
<table>
313374
<tr>

0 commit comments

Comments
 (0)