-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: make default value optional for ValueSignal (#3160)
* feat!: make default value optional for ValueSignal Fixes #2746 * add support for custom object types * remove comment out codes * fix bug and add tests * Apply suggestions from code review --------- Co-authored-by: Luciano Vernaschi <[email protected]>
- Loading branch information
Showing
6 changed files
with
710 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
packages/ts/generator-plugin-signals/test/fixtures/PrimitiveTypeValueSignalService.snap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { ArrayModel as ArrayModel_1, BooleanModel as BooleanModel_1, NumberModel as NumberModel_1, StringModel as StringModel_1 } from "@vaadin/hilla-lit-form"; | ||
import { ValueSignal as ValueSignal_1 } from "@vaadin/hilla-react-signals"; | ||
import client_1 from "./connect-client.default.js"; | ||
function anotherStringValueSignal_1(options?: { | ||
defaultValue: string; | ||
}): ValueSignal_1<string> { | ||
return new ValueSignal_1(options?.defaultValue ?? StringModel_1.createEmptyValue(), { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "anotherStringValueSignal" }); | ||
} | ||
function booleanValueSignal_1(options?: { | ||
defaultValue: boolean; | ||
}): ValueSignal_1<boolean> { | ||
return new ValueSignal_1(options?.defaultValue ?? BooleanModel_1.createEmptyValue(), { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "booleanValueSignal" }); | ||
} | ||
function booleanValueSignalNullable_1(options?: { | ||
defaultValue: boolean | undefined; | ||
}): ValueSignal_1<boolean | undefined> { | ||
return new ValueSignal_1(options?.defaultValue ?? undefined, { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "booleanValueSignalNullable" }); | ||
} | ||
function doubleValueSignal_1(options?: { | ||
defaultValue: number; | ||
}): ValueSignal_1<number> { | ||
return new ValueSignal_1(options?.defaultValue ?? NumberModel_1.createEmptyValue(), { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "doubleValueSignal" }); | ||
} | ||
function doubleValueSignalNullable_1(options?: { | ||
defaultValue: number | undefined; | ||
}): ValueSignal_1<number | undefined> { | ||
return new ValueSignal_1(options?.defaultValue ?? undefined, { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "doubleValueSignalNullable" }); | ||
} | ||
function stringArrayValueSignal_1(options?: { | ||
defaultValue: Array<string>; | ||
}): ValueSignal_1<Array<string>> { | ||
return new ValueSignal_1(options?.defaultValue ?? ArrayModel_1.createEmptyValue(), { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "stringArrayValueSignal" }); | ||
} | ||
function stringArrayValueSignalNullable_1(options?: { | ||
defaultValue: Array<string | undefined>; | ||
}): ValueSignal_1<Array<string | undefined>> { | ||
return new ValueSignal_1(options?.defaultValue ?? ArrayModel_1.createEmptyValue(), { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "stringArrayValueSignalNullable" }); | ||
} | ||
function stringValueSignal_1(options?: { | ||
defaultValue: string; | ||
}): ValueSignal_1<string> { | ||
return new ValueSignal_1(options?.defaultValue ?? StringModel_1.createEmptyValue(), { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "stringValueSignal" }); | ||
} | ||
function stringValueSignalNullable_1(options?: { | ||
defaultValue: string | undefined; | ||
}): ValueSignal_1<string | undefined> { | ||
return new ValueSignal_1(options?.defaultValue ?? undefined, { client: client_1, endpoint: "PrimitiveTypeValueSignalService", method: "stringValueSignalNullable" }); | ||
} | ||
export { anotherStringValueSignal_1 as anotherStringValueSignal, booleanValueSignal_1 as booleanValueSignal, booleanValueSignalNullable_1 as booleanValueSignalNullable, doubleValueSignal_1 as doubleValueSignal, doubleValueSignalNullable_1 as doubleValueSignalNullable, stringArrayValueSignal_1 as stringArrayValueSignal, stringArrayValueSignalNullable_1 as stringArrayValueSignalNullable, stringValueSignal_1 as stringValueSignal, stringValueSignalNullable_1 as stringValueSignalNullable }; |
31 changes: 19 additions & 12 deletions
31
packages/ts/generator-plugin-signals/test/fixtures/SignalServiceMix.snap.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,36 @@ | ||
import { EndpointRequestInit as EndpointRequestInit_1 } from "@vaadin/hilla-frontend"; | ||
import { ArrayModel as ArrayModel_1 } from "@vaadin/hilla-lit-form"; | ||
import { ListSignal as ListSignal_1, ValueSignal as ValueSignal_1 } from "@vaadin/hilla-react-signals"; | ||
import type Person_1 from "./com/github/taefi/data/Person.js"; | ||
import PersonModel_1 from "./com/github/taefi/data/PersonModel.js"; | ||
import client_1 from "./connect-client.default.js"; | ||
async function getPerson_1(init?: EndpointRequestInit_1): Promise<Person_1 | undefined> { return client_1.call("PersonService", "getPerson", {}, init); } | ||
function personArraySignal_1(options?: { | ||
defaultValue: Array<Person_1>; | ||
}): ValueSignal_1<Array<Person_1>> { | ||
return new ValueSignal_1(options?.defaultValue ?? ArrayModel_1.createEmptyValue(), { client: client_1, endpoint: "PersonService", method: "personArraySignal" }); | ||
} | ||
function personListSignal_1(): ListSignal_1<Person_1> { | ||
return new ListSignal_1({ client: client_1, endpoint: "PersonService", method: "personListSignal" }); | ||
} | ||
function personSignal_1({ defaultValue: defaultValue_1 }: { | ||
function personSignalNotNull_1(options?: { | ||
defaultValue: Person_1; | ||
}): ValueSignal_1<Person_1> { | ||
return new ValueSignal_1(options?.defaultValue ?? PersonModel_1.createEmptyValue(), { client: client_1, endpoint: "PersonService", method: "personSignalNotNull" }); | ||
} | ||
function personSignalNullable_1(isAdult: boolean, options?: { | ||
defaultValue: Person_1 | undefined; | ||
}): ValueSignal_1<Person_1 | undefined> { | ||
return new ValueSignal_1(defaultValue_1, { client: client_1, endpoint: "PersonService", method: "personSignal" }); | ||
return new ValueSignal_1(options?.defaultValue ?? undefined, { client: client_1, endpoint: "PersonService", method: "personSignalNullable", params: { isAdult } }); | ||
} | ||
function personSignalWithParams_1(dummyBoolean: boolean, dummyString: string | undefined, { defaultValue: defaultValue_2 }: { | ||
function personSignalWithParams_1(dummyBoolean: boolean, dummyString: string | undefined, options?: { | ||
defaultValue: Person_1 | undefined; | ||
}): ValueSignal_1<Person_1 | undefined> { | ||
return new ValueSignal_1(defaultValue_2, { client: client_1, endpoint: "PersonService", method: "personSignalWithParams", params: { dummyBoolean, dummyString } }); | ||
} | ||
function personSignalNonNull_1({ defaultValue: defaultValue_3 }: { | ||
defaultValue: Person_1; | ||
}): ValueSignal_1<Person_1> { | ||
return new ValueSignal_1(defaultValue_3, { client: client_1, endpoint: "PersonService", method: "personSignalNonNull" }); | ||
return new ValueSignal_1(options?.defaultValue ?? undefined, { client: client_1, endpoint: "PersonService", method: "personSignalWithParams", params: { dummyBoolean, dummyString } }); | ||
} | ||
function personSignalNonNullWithParams_1(dummyBoolean: boolean, dummyString: string | undefined, { defaultValue: defaultValue_4 }: { | ||
function personSignalNonNullWithParams_1(dummyBoolean: boolean, dummyString: string | undefined, options?: { | ||
defaultValue: Person_1; | ||
}): ValueSignal_1<Person_1> { | ||
return new ValueSignal_1(defaultValue_4, { client: client_1, endpoint: "PersonService", method: "personSignalNonNullWithParams", params: { dummyBoolean, dummyString } }); | ||
return new ValueSignal_1(options?.defaultValue ?? PersonModel_1.createEmptyValue(), { client: client_1, endpoint: "PersonService", method: "personSignalNonNullWithParams", params: { dummyBoolean, dummyString } }); | ||
} | ||
export { getPerson_1 as getPerson, personListSignal_1 as personListSignal, personSignal_1 as personSignal, personSignalNonNull_1 as personSignalNonNull, personSignalNonNullWithParams_1 as personSignalNonNullWithParams, personSignalWithParams_1 as personSignalWithParams }; | ||
export { getPerson_1 as getPerson, personArraySignal_1 as personArraySignal, personListSignal_1 as personListSignal, personSignalNonNullWithParams_1 as personSignalNonNullWithParams, personSignalNotNull_1 as personSignalNotNull, personSignalNullable_1 as personSignalNullable, personSignalWithParams_1 as personSignalWithParams }; |
Oops, something went wrong.