Skip to content

Commit 2eba07f

Browse files
committed
refactor(website): Update documentation to replace Rt.createState with Rt.registerState.
1 parent 558ea96 commit 2eba07f

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

website/src/content/docs/api/classes/rt_state.mdx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ abstract class RtState<E extends RtState<E>> {
4040
### Declaration
4141

4242
To create a custom state, extend the <HT>`RtState`</HT> class and define the state properties and methods.
43-
Register the state using <HM>[`Rt.createState`](/reactter/api/methods/state_management_methods/#rtcreatestate)</HM> or as a dependency within the Reactter framework, e.g.:
43+
Register the state using <HM>[`Rt.registerState`](/reactter/api/methods/state_management_methods/#rtregisterstate)</HM> or as a dependency within the Reactter framework, e.g.:
4444

45-
```dart collapse={13-20} mark={1,12} "RtState" "Rt.createState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
45+
```dart collapse={13-20} mark={1,12} "RtState" "Rt.registerState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
4646
class MyState extends RtState<MyState> {
4747
int _value = 0;
4848
int get value => _value;
@@ -54,7 +54,7 @@ class MyState extends RtState<MyState> {
5454
MyState([int value = 0]) : _value = value;
5555
}
5656
57-
final state = Rt.createState<MyState>(() => MyState()); // Register state
57+
final state = Rt.registerState<MyState>(() => MyState()); // Register state
5858
5959
Rt.on(
6060
state,
@@ -68,7 +68,7 @@ state.value = 42; // Calls update internally
6868
:::tip
6969
You can also use the factory constructor to create a state, e.g.:
7070

71-
```dart collapse={2-8, 15-21} mark={11-13} "RtState" "Rt.createState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
71+
```dart collapse={2-8, 15-21} mark={11-13} "RtState" "Rt.registerState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
7272
class MyState extends RtState<MyState> {
7373
int _value = 0;
7474
int get value => _value;
@@ -80,7 +80,7 @@ class MyState extends RtState<MyState> {
8080
MyState._([int value = 0]) : _value = value;
8181
8282
factory MyState(int value) {
83-
return Rt.createState(() => MyState._(value)); // Register state
83+
return Rt.registerState(() => MyState._(value)); // Register state
8484
}
8585
}
8686
@@ -93,14 +93,14 @@ Rt.on(
9393
state.value = 42; // Calls update internally
9494
```
9595

96-
This approach allows you to create a state directly without the need to call the <HM>`Rt.createState`</HM> method explicitly.
96+
This approach allows you to create a state directly without the need to call the <HM>`Rt.registerState`</HM> method explicitly.
9797
:::
9898

9999
### Updating the state
100100

101101
To update the state, call the <HM>`update`</HM> method and provide a callback function that modifies the state, e.g.:
102102

103-
```dart collapse={2-3, 8-13} mark={6, 22} "RtState" "Rt.createState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
103+
```dart collapse={2-3, 8-13} mark={6, 22} "RtState" "Rt.registerState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
104104
class MyState extends RtState<MyState> {
105105
int _value = 0;
106106
int get value => _value;
@@ -112,7 +112,7 @@ class MyState extends RtState<MyState> {
112112
MyState._([int value = 0]) : _value = value;
113113
114114
factory MyState(int value) {
115-
return Rt.createState(() => MyState._(value)); // Register state
115+
return Rt.registerState(() => MyState._(value)); // Register state
116116
}
117117
}
118118
@@ -132,7 +132,7 @@ When a state is updated, it emits the following lifecycle events:
132132
- <HE>`Lifecycle.willUpdate`</HE> event is triggered before the callback function of <HM>`update`</HM> method have been executed.
133133
- <HE>`Lifecycle.didUpdate`</HE> event is triggered after the callback function of <HM>`update`</HM> method have been executed or after the <HM>`notify`</HM> method have been invoked.
134134

135-
```dart collapse={2-3, 8-13} mark={16-20} "RtState" "Rt.createState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
135+
```dart collapse={2-3, 8-13} mark={16-20} "RtState" "Rt.registerState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
136136
class MyState extends RtState<MyState> {
137137
int _value = 0;
138138
int get value => _value;
@@ -144,7 +144,7 @@ class MyState extends RtState<MyState> {
144144
MyState._([int value = 0]) : _value = value;
145145
146146
factory MyState(int value) {
147-
return Rt.createState(() => MyState._(value)); // Register state
147+
return Rt.registerState(() => MyState._(value)); // Register state
148148
}
149149
}
150150

website/src/content/docs/api/methods/state_management_methods.mdx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,28 +64,28 @@ void main() {
6464
In the example, the `uCount` state is lazily declared inside the <HT>`CountController`</HT> class using <HM>`Rt.lazyState`</HM>. It's accessed after creating the <HT>`CountController`</HT> instance, and when the instance is deleted, the state is automatically disposed, ensuring efficient resource management.
6565

6666

67-
## <HM>`Rt.createState`</HM>
67+
## <HM>`Rt.registerState`</HM>
6868

69-
<HM>`Rt.createState`</HM> is a method that allows to register a <HT>[`RtState`](/reactter/api/classes/rt_state)</HT> instance.
69+
<HM>`Rt.registerState`</HM> is a method that allows to register a <HT>[`RtState`](/reactter/api/classes/rt_state)</HT> instance.
7070
All states created must be registered using this method for proper management and disposal.
7171

7272
:::note
73-
In most cases, you don't need to manually use the `Rt.createState` method to create a state when using `RtHook` or `Signal` classes, as they automatically handle the registration of the state instance.
73+
In most cases, you don't need to manually use the <HM>`Rt.registerState`</HM> method to create a state when using <HT>[`RtHook`](/reactter/api/classes/rt_hook)</HT> or <HT>[`Signal`](/reactter/api/classes/signal)</HT> classes, as they automatically handle the registration of the state instance.
7474

75-
However, if you're creating a custom state using the `RtState` class directly, you **must** use `Rt.createState` to properly register the state instance.
75+
However, if you're creating a custom state using the <HT>[`RtState`](/reactter/api/classes/rt_state)</HT> class directly, you **must** use <HM>`Rt.registerState`</HM> to properly register the state instance.
7676
:::
7777

7878
#### Syntax
7979

8080
```dart showLineNumbers=false
81-
T Rt.createState<T extends RtState>(T stateFn());
81+
T Rt.registerState<T extends RtState>(T stateFn());
8282
```
8383

8484
#### Example
8585

86-
In this example, the custom state using <HT>[`RtState`](/reactter/api/classes/rt_state)</HT> class is created and registered using <HM>`Rt.createState`</HM> method.
86+
In this example, the custom state using <HT>[`RtState`](/reactter/api/classes/rt_state)</HT> class is created and registered using <HM>`Rt.registerState`</HM> method.
8787

88-
```dart collapse={13-20} mark={1,12} "RtState" "Rt.createState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
88+
```dart collapse={13-20} mark={1,12} "RtState" "Rt.registerState" "Rt.on" "Lifecycle.didUpdate" /update(?=\u0028)/
8989
class MyState extends RtState<MyState> {
9090
int _value = 0;
9191
int get value => _value;
@@ -97,7 +97,7 @@ class MyState extends RtState<MyState> {
9797
MyState([int value = 0]) : _value = value;
9898
}
9999
100-
final state = Rt.createState<MyState>(() => MyState()); // Register state
100+
final state = Rt.registerState<MyState>(() => MyState()); // Register state
101101
102102
Rt.on(
103103
state,

0 commit comments

Comments
 (0)