Skip to content

createSvgAsync<K>

Creates a svg asynchronously.

Not refactored to parameter-object pattern, to keep the parity with obsidian#createSvg (or createEl, correspondingly).

Import:

import { createSvgAsync } from 'obsidian-dev-utils/html-element';

Signature:

function createSvgAsync(tag: K, o: string | SvgElementInfo | undefined, callback: ((el: SVGElementTagNameMap[K]) => Promisable<void>) | undefined): Promise<SVGElementTagNameMap[K]>

Parameters:

ParameterTypeDescription
tagKThe tag name of the svg to create.
ostring | SvgElementInfo | undefinedThe svg information.
callback((el: SVGElementTagNameMap[K]) => Promisable<void>) | undefinedThe callback to call when the svg is created.

Returns: Promise<SVGElementTagNameMap[K]> — A Promise that resolves to the svg.