jazz-tools 0.8.23 → 0.8.27
Sign up to get free protection for your applications and to get access to all the features.
package/CHANGELOG.md
CHANGED
@@ -6,6 +6,7 @@ import { CoValueBase, } from "../internal.js";
|
|
6
6
|
* Declare your union types by extending `SchemaUnion.Of(...)` and passing a discriminator function
|
7
7
|
* that determines which concrete type to use based on the raw data.
|
8
8
|
*
|
9
|
+
* @example
|
9
10
|
* ```ts
|
10
11
|
* import { SchemaUnion, CoMap } from "jazz-tools";
|
11
12
|
*
|
@@ -37,8 +38,9 @@ import { CoValueBase, } from "../internal.js";
|
|
37
38
|
* When loading a SchemaUnion, the correct subclass will be instantiated based on the discriminator.
|
38
39
|
* You can narrow the returned instance to a subclass by using `instanceof` like so:
|
39
40
|
*
|
41
|
+
* @example
|
40
42
|
* ```ts
|
41
|
-
* const widget = await WidgetUnion
|
43
|
+
* const widget = await loadCoValue(WidgetUnion, id, me, {});
|
42
44
|
* if (widget instanceof ButtonWidget) {
|
43
45
|
* console.log(widget.label);
|
44
46
|
* } else if (widget instanceof SliderWidget) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schemaUnion.js","sourceRoot":"","sources":["../../../src/coValues/schemaUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB
|
1
|
+
{"version":3,"file":"schemaUnion.js","sourceRoot":"","sources":["../../../src/coValues/schemaUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,OAAgB,WAAY,SAAQ,WAAW;IACnD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,EAAE,CACP,aAAsE;QAEtE,OAAO,MAAM,gBAAiB,SAAQ,WAAW;YAC/C,MAAM,CAAU,OAAO,CAErB,GAAc;gBAEd,MAAM,aAAa,GAAG,aAAa,CACjC,GAAgB,CACiC,CAAC;gBACpD,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACpC,CAAC;SACiD,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,aAAa;IACb,MAAM,CAAC,OAAO,CAA2C,GAAc;QACrE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF"}
|
@@ -6,6 +6,7 @@ import { CoValueBase, } from "../internal.js";
|
|
6
6
|
* Declare your union types by extending `SchemaUnion.Of(...)` and passing a discriminator function
|
7
7
|
* that determines which concrete type to use based on the raw data.
|
8
8
|
*
|
9
|
+
* @example
|
9
10
|
* ```ts
|
10
11
|
* import { SchemaUnion, CoMap } from "jazz-tools";
|
11
12
|
*
|
@@ -37,8 +38,9 @@ import { CoValueBase, } from "../internal.js";
|
|
37
38
|
* When loading a SchemaUnion, the correct subclass will be instantiated based on the discriminator.
|
38
39
|
* You can narrow the returned instance to a subclass by using `instanceof` like so:
|
39
40
|
*
|
41
|
+
* @example
|
40
42
|
* ```ts
|
41
|
-
* const widget = await WidgetUnion
|
43
|
+
* const widget = await loadCoValue(WidgetUnion, id, me, {});
|
42
44
|
* if (widget instanceof ButtonWidget) {
|
43
45
|
* console.log(widget.label);
|
44
46
|
* } else if (widget instanceof SliderWidget) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"schemaUnion.js","sourceRoot":"","sources":["../../../src/coValues/schemaUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB
|
1
|
+
{"version":3,"file":"schemaUnion.js","sourceRoot":"","sources":["../../../src/coValues/schemaUnion.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,WAAW,GAGZ,MAAM,gBAAgB,CAAC;AAExB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkDG;AACH,MAAM,OAAgB,WAAY,SAAQ,WAAW;IACnD;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,MAAM,CAAC,EAAE,CACP,aAAsE;QAEtE,OAAO,MAAM,gBAAiB,SAAQ,WAAW;YAC/C,MAAM,CAAU,OAAO,CAErB,GAAc;gBAEd,MAAM,aAAa,GAAG,aAAa,CACjC,GAAgB,CACiC,CAAC;gBACpD,OAAO,aAAa,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACpC,CAAC;SACiD,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,aAAa;IACb,MAAM,CAAC,OAAO,CAA2C,GAAc;QACrE,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACrC,CAAC;CACF"}
|
package/package.json
CHANGED
@@ -12,6 +12,7 @@ import {
|
|
12
12
|
* Declare your union types by extending `SchemaUnion.Of(...)` and passing a discriminator function
|
13
13
|
* that determines which concrete type to use based on the raw data.
|
14
14
|
*
|
15
|
+
* @example
|
15
16
|
* ```ts
|
16
17
|
* import { SchemaUnion, CoMap } from "jazz-tools";
|
17
18
|
*
|
@@ -43,8 +44,9 @@ import {
|
|
43
44
|
* When loading a SchemaUnion, the correct subclass will be instantiated based on the discriminator.
|
44
45
|
* You can narrow the returned instance to a subclass by using `instanceof` like so:
|
45
46
|
*
|
47
|
+
* @example
|
46
48
|
* ```ts
|
47
|
-
* const widget = await WidgetUnion
|
49
|
+
* const widget = await loadCoValue(WidgetUnion, id, me, {});
|
48
50
|
* if (widget instanceof ButtonWidget) {
|
49
51
|
* console.log(widget.label);
|
50
52
|
* } else if (widget instanceof SliderWidget) {
|