async-replace.d.ts 1.9 KB

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