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