fix(core): update
This commit is contained in:
parent
f4b8260c45
commit
67927cc3a2
@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@designestate/dees-element',
|
name: '@designestate/dees-element',
|
||||||
version: '2.0.18',
|
version: '2.0.19',
|
||||||
description: 'a custom element class extending lit element class'
|
description: 'a custom element class extending lit element class'
|
||||||
}
|
}
|
||||||
|
37
ts/dees-element.classes.asyncdirective.ts
Normal file
37
ts/dees-element.classes.asyncdirective.ts
Normal 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);
|
@ -16,7 +16,8 @@ import * as domtools from '@designestate/dees-domtools';
|
|||||||
export { domtools };
|
export { domtools };
|
||||||
|
|
||||||
// DeesElements exports
|
// 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
|
* a singleton instance of CssManager
|
||||||
|
Loading…
Reference in New Issue
Block a user