Create Libraries and basic tooltip
This commit is contained in:
1
libs/_internal/directives/src/index.ts
Normal file
1
libs/_internal/directives/src/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { asyncDirective } from './lib/async-directive';
|
||||
28
libs/_internal/directives/src/lib/async-directive.ts
Normal file
28
libs/_internal/directives/src/lib/async-directive.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { noChange } from 'lit';
|
||||
import { AsyncDirective, directive } from 'lit/async-directive.js';
|
||||
import { Observable, Subject, tap } from 'rxjs';
|
||||
|
||||
class Async extends AsyncDirective {
|
||||
private readonly destroy$ = new Subject<void>();
|
||||
|
||||
render(observable: Observable<unknown>) {
|
||||
observable
|
||||
.pipe(
|
||||
tap((value: unknown) => {
|
||||
this.setValue(value);
|
||||
}),
|
||||
)
|
||||
.subscribe();
|
||||
|
||||
return noChange;
|
||||
}
|
||||
|
||||
protected override disconnected(): void {
|
||||
super.disconnected();
|
||||
|
||||
this.destroy$.next();
|
||||
this.destroy$.complete();
|
||||
}
|
||||
}
|
||||
|
||||
export const asyncDirective = directive(Async);
|
||||
Reference in New Issue
Block a user