API Reference / @gtkx/runtime / fromVariant
Variable: fromVariant
constfromVariant: <S>(typeString,variant) =>VariantValue<S>
Defined in: packages/runtime/dist/variant.d.ts:83
Unpacks a GLib.Variant into the JavaScript value a GVariant type string describes, the inverse of toVariant. A dictionary keyed by strings unpacks to a record and one keyed by anything else to a Map, an array to an array, a tuple to an array of its members, a maybe to its value or null, and a nested variant to the GLib.Variant itself.
Type Parameters
S
S extends string
Parameters
typeString
S
GVariant type the variant holds, such as "a{sv}".
variant
GLib.Variant
Variant to read, which has to hold that type.
Returns
VariantValue<S>
The unpacked value, typed from typeString when it is given as a literal.
Throws
When the type string is not one complete GVariant type.