fix(directives): Add explicit type annotations to subscribeWithTemplate directive export
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import { type TemplateResult, noChange } from 'lit';
|
||||
import type { DirectiveResult } from 'lit/directive.js';
|
||||
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
||||
import { rxjs } from '@push.rocks/smartrx';
|
||||
|
||||
@ -48,4 +49,13 @@ class SubscribeWithTemplateDirective extends AsyncDirective {
|
||||
* Directive that renders templates for each emission of an Observable.
|
||||
* Usage: html`${subscribeWithTemplate(myObservable, v => html`<span>${v}</span>`)}`
|
||||
*/
|
||||
export const subscribeWithTemplate = directive(SubscribeWithTemplateDirective);
|
||||
/**
|
||||
* Typed directive function signature: returns a Lit DirectiveResult.
|
||||
*/
|
||||
type SubscribeWithTemplateFn = <T>(
|
||||
observable: rxjs.Observable<T>,
|
||||
templateFn: (value: T) => TemplateResult | unknown
|
||||
) => DirectiveResult;
|
||||
export const subscribeWithTemplate = directive(
|
||||
SubscribeWithTemplateDirective
|
||||
) as SubscribeWithTemplateFn;
|
Reference in New Issue
Block a user