Skip to content

Commit

Permalink
fix: update serializer example
Browse files Browse the repository at this point in the history
  • Loading branch information
marcus-pousette committed Jan 17, 2024
1 parent 1b3477c commit 362f1a1
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class TestStruct {

@field({type: 'u8'})
public number: number;

constructor(number: number) {
this.number = number;
}
Expand All @@ -269,13 +269,10 @@ class TestStruct {

@serializer()
override(writer: BinaryWriter, serialize: (obj: this) => Uint8Array) {
if (this.cache) {
writer.set(this.cache)
}
else {
if (!this.cache) {
this.cache = serialize(this)
writer.set(this.cache)
}
writer.set(this.cache)
}
}

Expand Down

0 comments on commit 362f1a1

Please sign in to comment.