diff --git a/demo/app-root.ts b/demo/app-root.ts index 89f9ab1..eb66975 100644 --- a/demo/app-root.ts +++ b/demo/app-root.ts @@ -4,13 +4,12 @@ import { customElement } from 'lit/decorators.js'; // Lit's html`` tag cannot render variable tag names directly. import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -const storyModules = import.meta.glob( - ['../src/elements/**/*-story.ts', '../src/labs/**/*-story.ts'], - { eager: true } -); +const storyModules = import.meta.glob(['../src/**/*-story.ts'], { + eager: true, +}); const storyEntries = Object.keys(storyModules) - .map(path => { + .map((path) => { const labs = path.includes('/src/labs/'); const parts = path.split('/'); const filename = parts[parts.length - 1]; // e.g. "ia-button-story.ts" @@ -19,13 +18,15 @@ const storyEntries = Object.keys(storyModules) }) .sort((a, b) => a.tag.localeCompare(b.tag)); -const productionEntries = storyEntries.filter(e => !e.labs); -const labsEntries = storyEntries.filter(e => e.labs); +const productionEntries = storyEntries.filter((e) => !e.labs); +const labsEntries = storyEntries.filter((e) => e.labs); const ALL_ENTRIES = [...productionEntries, ...labsEntries]; @customElement('app-root') export class AppRoot extends LitElement { - createRenderRoot() { return this; } + createRenderRoot() { + return this; + } private _observer?: IntersectionObserver; private _abortController = new AbortController(); @@ -34,33 +35,42 @@ export class AppRoot extends LitElement { return html`
+ A typed container for a response: it carries either a
+ success value or a typed error, instead of
+ an untyped Promise rejection. Modeled after
+ Swift's Result. Toggle a scenario to see the two shapes and how a caller handles
+ each.
+
${this.formatResult(result)}
+
+ ${result.error
+ ? html`โ handle error โ ${result.error.message}`
+ : html`โ use value โ ${result.success}`}
+
+