2023-01-02 11:09:47 +01:00
|
|
|
import { Observable } from 'rxjs';
|
|
|
|
|
import { UmbObserver } from './observer';
|
2023-01-20 13:28:41 +01:00
|
|
|
import { UmbControllerInterface, UmbControllerHostInterface } from '@umbraco-cms/controller';
|
2023-01-02 11:09:47 +01:00
|
|
|
|
2023-01-04 09:31:16 +01:00
|
|
|
export class UmbObserverController<T> extends UmbObserver<T> implements UmbControllerInterface {
|
2023-01-12 09:55:51 +01:00
|
|
|
_alias?: string;
|
|
|
|
|
public get unique() {
|
|
|
|
|
return this._alias;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 13:28:41 +01:00
|
|
|
constructor(host: UmbControllerHostInterface, source: Observable<T>, callback: (_value: T) => void, alias?: string) {
|
2023-01-10 21:54:53 +01:00
|
|
|
super(source, callback);
|
2023-01-12 09:55:51 +01:00
|
|
|
this._alias = alias;
|
|
|
|
|
|
|
|
|
|
// Lets check if controller is already here:
|
|
|
|
|
/*
|
|
|
|
|
if (this._subscriptions.has(source)) {
|
|
|
|
|
const subscription = this._subscriptions.get(source);
|
|
|
|
|
subscription?.unsubscribe();
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
2023-01-10 21:54:53 +01:00
|
|
|
host.addController(this);
|
|
|
|
|
}
|
2023-01-02 11:09:47 +01:00
|
|
|
|
|
|
|
|
hostConnected() {
|
2023-01-10 21:54:53 +01:00
|
|
|
return;
|
2023-01-02 11:09:47 +01:00
|
|
|
}
|
2023-01-10 21:54:53 +01:00
|
|
|
}
|