fix(core): update

This commit is contained in:
Philipp Kunz 2023-03-15 22:22:30 +01:00
parent f4b8260c45
commit 67927cc3a2
3 changed files with 40 additions and 2 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@designestate/dees-element',
version: '2.0.18',
version: '2.0.19',
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 SubscribeDirective 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 subscribe = directive(SubscribeDirective);

View File

@ -16,7 +16,8 @@ import * as domtools from '@designestate/dees-domtools';
export { domtools };
// DeesElements exports
export { DeesElement } from './dees-element.classes.dees-element.js';
export * from './dees-element.classes.dees-element.js';
export * from './dees-element.classes.asyncdirective.js';
/**
* a singleton instance of CssManager