Skip to content

Commit

Permalink
Updated doc
Browse files Browse the repository at this point in the history
  • Loading branch information
janwuesten committed Jan 22, 2024
1 parent 43b8c8a commit 5f44347
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 38 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ class Country extends Definable {
countryCode: string = ""

definition({ prop }: DefinableDefinition): void {
prop("name")
.useDeserializer<string>((data) => this.name = data ?? "")
.useSerializer<string>(() => this.name)
prop("countryCode")
.useDeserializer<string>((data) => this.countryCode = data ?? "")
.useSerializer<string>(() => this.countryCode)
prop<string>("name")
.useDeserializer((data) => this.name = data ?? "")
.useSerializer(() => this.name)
prop<string>("countryCode")
.useDeserializer((data) => this.countryCode = data ?? "")
.useSerializer(() => this.countryCode)
}
}

Expand Down
8 changes: 4 additions & 4 deletions docs/docs/definable/base-class.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class MyFirstClass extends Definable {

//highlight-start
definition({ prop }: DefinableDefinition): void {
prop("myFirstProperty")
prop<string>("myFirstProperty")
}
//highlight-end
}
Expand All @@ -64,11 +64,11 @@ class MyFirstClass extends Definable {
myFirstProperty: string = ""

definition({ prop }: DefinableDefinition): void {
prop("myFirstProperty")
prop<string>("myFirstProperty")
//highlight-start
.useSerializer<string>(() => this.myFirstProperty)
.useSerializer(() => this.myFirstProperty)
// data will have the type "string | null"
.useDeserializer<string>((data) => this.myFirstProperty = data ?? "")
.useDeserializer((data) => this.myFirstProperty = data ?? "")
//highlight-end
}

Expand Down
18 changes: 9 additions & 9 deletions docs/docs/definable/deserialize.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class Country extends Definable {
population: number = 83200000

definition({ prop }: DefinableDefinition): void {
prop("name")
.useDeserializer<string>((data) => this.name = data ?? "")
.useSerializer<string>(() => this.name)
prop("code")
.useDeserializer<string>((data) => this.code = data ?? "")
.useSerializer<string>(() => this.code)
prop("population")
.useDeserializer<number>((data) => this.population = data ?? 0)
.useSerializer<number>(() => this.population)
prop<string>("name")
.useDeserializer((data) => this.name = data ?? "")
.useSerializer(() => this.name)
prop<string>("code")
.useDeserializer((data) => this.code = data ?? "")
.useSerializer(() => this.code)
prop<number>("population")
.useDeserializer((data) => this.population = data ?? 0)
.useSerializer(() => this.population)
}
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/docs/definable/events.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ class MyFirstClass extends Definable {
})
//highlight-end

prop("myFirstProperty")
.useSerializer<string>(() => this.myFirstProperty)
prop<string>("myFirstProperty")
.useSerializer(() => this.myFirstProperty)
// data will have the type "string | null"
.useDeserializer<string>((data) => this.myFirstProperty = data ?? "")
.useDeserializer((data) => this.myFirstProperty = data ?? "")
}

}
Expand Down
18 changes: 9 additions & 9 deletions docs/docs/definable/serialize.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ class Country extends Definable {
population: number = 83200000

definition({ prop }: DefinableDefinition): void {
prop("name")
.useDeserializer<string>((data) => this.name = data ?? "")
.useSerializer<string>(() => this.name)
prop("code")
.useDeserializer<string>((data) => this.code = data ?? "")
.useSerializer<string>(() => this.code)
prop("population")
.useDeserializer<number>((data) => this.population = data ?? 0)
.useSerializer<number>(() => this.population)
prop<string>("name")
.useDeserializer((data) => this.name = data ?? "")
.useSerializer(() => this.name)
prop<string>("code")
.useDeserializer((data) => this.code = data ?? "")
.useSerializer(() => this.code)
prop<number>("population")
.useDeserializer((data) => this.population = data ?? 0)
.useSerializer(() => this.population)
}
}
```
Expand Down
12 changes: 6 additions & 6 deletions docs/docs/definable/validation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ class Country extends Definable {
code: string = ""

definition({ prop }: DefinableDefinition): void {
prop("code")
.useDeserializer<string>((data) => this.code = data ?? "")
.useSerializer<string>(() => this.code)
prop<string>("code")
.useDeserializer((data) => this.code = data ?? "")
.useSerializer(() => this.code)
}
}
```
Expand All @@ -41,7 +41,7 @@ class Country extends Definable {
code: string = ""

definition({ prop }: DefinableDefinition): void {
prop("code")
prop<string>("code")
//highlight-start
.useValidator(() => {
if (!this.code) {
Expand All @@ -53,8 +53,8 @@ class Country extends Definable {
return null
})
//highlight-end
.useDeserializer<string>((data) => this.code = data ?? "")
.useSerializer<string>(() => this.code)
.useDeserializer((data) => this.code = data ?? "")
.useSerializer(() => this.code)
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion test/extension.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class BaseClass extends Definable {
class ExtendedClass extends BaseClass {
definition({ prop, event }: DefinableDefinition): void {
super.definition({ prop, event })
prop("testProp")
prop<string>("testProp")
.useSerializer(() => this.testProp.toUpperCase())
}
}
Expand Down

0 comments on commit 5f44347

Please sign in to comment.