You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<p><code>IManualState.Restart</code> will be called right before the element gets reused from the Pool. Do not use <code>Restart</code> to unsubscribe from events or cancel actions. Use <code>ComponentWillUnmount</code> for that.</p>
158
+
<p><code>IManualState.Restart</code> will be called right before the element gets reused from the Pool. Do not use <code>Restart</code> to unsubscribe from events or cancel actions. Use <code>ElementWillUnmount</code> for that.</p>
159
159
</div>
160
160
</div>
161
161
@@ -170,10 +170,10 @@ If you implement `ICustomUnmountListener`:
170
170
{% highlight csharp %}
171
171
public partial class DelaySampleElement : RishElement, IMountingListener, ICustomUnmountListener
172
172
{
173
-
void IMountingListener.ComponentDidMount() {
173
+
void IMountingListener.ElementDidMount() {
174
174
Debug.Log("1. Element was added to the tree.");
175
175
}
176
-
void IMountingListener.ComponentWillUnmount() {
176
+
void IMountingListener.ElementWillUnmount() {
177
177
Debug.Log("4. Element is about to be removed from the tree.");
178
178
}
179
179
@@ -250,8 +250,8 @@ public partial class FooElement : RishElement<FooProps, FooState>, IPropsListene
250
250
251
251
[RishValueType]
252
252
public struct FooProps {
253
-
[DOMDescriptor]
254
-
public DOMDescriptor descriptor; // descriptor can change and it won't trigger another setup
253
+
[Expand]
254
+
public VisualAttributes descriptor; // descriptor can change and it won't trigger another setup
255
255
256
256
public int id; // if id changes, Setup will be called
Copy file name to clipboardExpand all lines: _auto_docs/rish/06-memory-management.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,7 +122,7 @@ You can leverage Rish's high-performance pooling system for your own data struct
122
122
123
123
To create a custom pooled type:
124
124
1.**The Reference:** Create a class that implements `IManaged` (must have a parameterless constructor).
125
-
2.**The Pointer:** Create a struct that implements `IReference`.
125
+
2.**The Pointer:** Create a struct that implements `IPointer`.
126
126
127
127
Once implemented, Rish will automatically pool instances of your class and allow you to use them safely within Managed Contexts, just like native Rish types.
public static RishUI.Element Create() => Create(default(ulong), default(RishUI.DOMDescriptor), default(FooProps), default(RishUI.Children));
167
+
public static RishUI.Element Create() => Create(default(ulong), default(RishUI.VisualAttributes), default(FooProps), default(RishUI.Children));
168
168
[RishUI.MemoryManagement.RequiresManagedContext]
169
-
public static RishUI.Element Create(ulong key) => Create(key, default(RishUI.DOMDescriptor), default(FooProps), default(RishUI.Children));
169
+
public static RishUI.Element Create(ulong key) => Create(key, default(RishUI.VisualAttributes), default(FooProps), default(RishUI.Children));
170
170
[RishUI.MemoryManagement.RequiresManagedContext]
171
-
public static RishUI.Element Create(RishUI.DOMDescriptor descriptor) => Create(default(ulong), descriptor, default(FooProps), default(RishUI.Children));
171
+
public static RishUI.Element Create(RishUI.VisualAttributes descriptor) => Create(default(ulong), descriptor, default(FooProps), default(RishUI.Children));
172
172
[RishUI.MemoryManagement.RequiresManagedContext]
173
-
public static RishUI.Element Create(RishUI.Name name) => Create(default(ulong), new RishUI.DOMDescriptor { name = name }, default(FooProps), default(RishUI.Children));
173
+
public static RishUI.Element Create(RishUI.Name name) => Create(default(ulong), new RishUI.VisualAttributes { name = name }, default(FooProps), default(RishUI.Children));
174
174
[RishUI.MemoryManagement.RequiresManagedContext]
175
-
public static RishUI.Element Create(RishUI.ClassName className) => Create(default(ulong), new RishUI.DOMDescriptor { className = className }, default(FooProps), default(RishUI.Children));
175
+
public static RishUI.Element Create(RishUI.ClassName className) => Create(default(ulong), new RishUI.VisualAttributes { className = className }, default(FooProps), default(RishUI.Children));
176
176
[RishUI.MemoryManagement.RequiresManagedContext]
177
-
public static RishUI.Element Create(RishUI.Style style) => Create(default(ulong), new RishUI.DOMDescriptor { style = style }, default(FooProps), default(RishUI.Children));
177
+
public static RishUI.Element Create(RishUI.Style style) => Create(default(ulong), new RishUI.VisualAttributes { style = style }, default(FooProps), default(RishUI.Children));
<li><code>key</code>: Always reserved for Element Keys.</li>
190
-
<li><code>name</code>, <code>className</code> and <code>style</code>: Reserved in VisualElements and RishElements with expanded <code>DOMDescriptors</code>.</li>
190
+
<li><code>name</code>, <code>className</code> and <code>style</code>: Reserved in VisualElements and RishElements with expanded <code>VisualAttributess</code>.</li>
191
191
<li><code>children</code>: Reserved in VisualElements.</li>
public partial class CachedLambdasExample : RishElement<CachedLambdasExampleProps>, IMountingListener
183
183
{
184
-
void IMountingListener.ComponentDidMount()
184
+
void IMountingListener.ElementDidMount()
185
185
{
186
186
// ✅ Every time the element is mounted, we are reusing the same instance generated by Rishenerator.
187
187
VolumeLevel.OnChange += SappyState.SetVolume;
188
188
}
189
-
void IMountingListener.ComponentWillUnmount()
189
+
void IMountingListener.ElementWillUnmount()
190
190
{
191
191
// ✅ Every time the element is unmounted, we are reusing the same instance generated by Rishenerator.
192
192
VolumeLevel.OnChange -= SappyState.SetVolume;
@@ -397,8 +397,8 @@ When it comes to best practices styling VisualElements, UI Toolkit is king. You
397
397
Interfaces are implemented explicitly.
398
398
399
399
{% highlight csharp %}
400
-
void IMountingListener.ComponentDidMount() { }
401
-
void IMountingListener.ComponentWillUnmount() { }
400
+
void IMountingListener.ElementDidMount() { }
401
+
void IMountingListener.ElementWillUnmount() { }
402
402
{% endhighlight %}
403
403
404
404
You should not call any of these lifecycle methods manually and implementing them explicitly adds extra friction to prevent you from calling them by accident.
0 commit comments