fix(core): update

This commit is contained in:
Philipp Kunz 2023-03-29 20:29:12 +02:00
parent 6da377f0f6
commit fe50d39d01
4 changed files with 40 additions and 2 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@designestate/dees-element',
version: '2.0.20',
version: '2.0.21',
description: 'a custom element class extending lit element class'
}

View File

@ -0,0 +1,37 @@
import { noChange } from 'lit';
import { AsyncDirective, directive } from 'lit/async-directive.js';
import { rxjs } from '@pushrocks/smartrx';
class ResolveDirective extends AsyncDirective {
observable: rxjs.Observable<unknown> | undefined;
sub: rxjs.Subscription | null = null;
render(observable: rxjs.Observable<unknown>) {
if (this.observable !== observable) {
this.sub?.unsubscribe();
this.observable = observable;
if (this.isConnected) {
this.subscribe(observable);
}
}
return noChange;
}
subscribe(observable: rxjs.Observable<unknown>) {
this.sub = observable.subscribe((v: unknown) => {
this.setValue(v);
});
}
disconnected() {
this.sub?.unsubscribe();
}
reconnected() {
this.subscribe(this.observable!);
}
}
export const resolve = directive(ResolveDirective);

View File

@ -17,7 +17,8 @@ export { domtools };
// DeesElements exports
export * from './dees-element.classes.dees-element.js';
export * from './dees-element.classes.asyncdirective.js';
export * from './dees-element.classes.subscribedirective.js';
export * from './dees-element.classes.resolvedirective.js';
/**
* a singleton instance of CssManager