Skip to content

Commit

Permalink
doc: Adding a tip on how to create the 'copyWith' method for custom c…
Browse files Browse the repository at this point in the history
…lasses
  • Loading branch information
klkucaj committed Dec 5, 2024
1 parent 5b282c0 commit 1e82a44
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/06-concepts/03-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ For most purposes, you will want to use Serverpod's native serialization. Howeve
```
3. There must be a method called `copyWith()`, which returns a new instance of the object with the specified fields replaced.
:::tip
In the framework, `copyWith()` is implemented as a deep copy to ensure immutability. We recommend following this approach when implementing it for custom classes to avoid unintentional side effects caused by shared mutable references.
:::
```dart
ClassName copyWith({
Expand Down

0 comments on commit 1e82a44

Please sign in to comment.