keyed.d.ts 1.0 KB

123456789101112131415161718192021222324252627282930
  1. /**
  2. * @license
  3. * Copyright 2021 Google LLC
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. import { Directive, ChildPart, DirectiveParameters, DirectiveResult } from '../directive.js';
  7. declare class Keyed<T> extends Directive {
  8. key: unknown;
  9. render(k: unknown, v: T): T;
  10. update(part: ChildPart, [k, v]: DirectiveParameters<this>): T;
  11. }
  12. interface KeyedFunc {
  13. <V>(k: unknown, v: V): DirectiveResult<typeof Keyed<V>>;
  14. }
  15. /**
  16. * Associates a renderable value with a unique key. When the key changes, the
  17. * previous DOM is removed and disposed before rendering the next value, even
  18. * if the value - such as a template - is the same.
  19. *
  20. * This is useful for forcing re-renders of stateful components, or working
  21. * with code that expects new data to generate new HTML elements, such as some
  22. * animation techniques.
  23. */
  24. export declare const keyed: KeyedFunc;
  25. /**
  26. * The type of the class that powers this directive. Necessary for naming the
  27. * directive's return type.
  28. */
  29. export type { Keyed };
  30. //# sourceMappingURL=keyed.d.ts.map