async-replace.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @license
  3. * Copyright 2017 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import { ChildPart } from '../lit-html.js';
  7. import { AsyncDirective, DirectiveParameters } from '../async-directive.js';
  8. type Mapper<T> = (v: T, index?: number) => unknown;
  9. export declare class AsyncReplaceDirective extends AsyncDirective {
  10. private __value?;
  11. private __weakThis;
  12. private __pauser;
  13. render<T>(value: AsyncIterable<T>, _mapper?: Mapper<T>): symbol;
  14. update(_part: ChildPart, [value, mapper]: DirectiveParameters<this>): symbol;
  15. protected commitValue(value: unknown, _index: number): void;
  16. disconnected(): void;
  17. reconnected(): void;
  18. }
  19. /**
  20. * A directive that renders the items of an async iterable[1], replacing
  21. * previous values with new values, so that only one value is ever rendered
  22. * at a time. This directive may be used in any expression type.
  23. *
  24. * Async iterables are objects with a `[Symbol.asyncIterator]` method, which
  25. * returns an iterator who's `next()` method returns a Promise. When a new
  26. * value is available, the Promise resolves and the value is rendered to the
  27. * Part controlled by the directive. If another value other than this
  28. * directive has been set on the Part, the iterable will no longer be listened
  29. * to and new values won't be written to the Part.
  30. *
  31. * [1]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of
  32. *
  33. * @param value An async iterable
  34. * @param mapper An optional function that maps from (value, index) to another
  35. * value. Useful for generating templates for each item in the iterable.
  36. */
  37. export declare const asyncReplace: (value: AsyncIterable<unknown>, _mapper?: Mapper<unknown> | undefined) => import("../directive.js").DirectiveResult<typeof AsyncReplaceDirective>;
  38. export {};
  39. //# sourceMappingURL=async-replace.d.ts.map