fa234b9a9b
- Fixes: - Fixing time based issue in `ConnectivityManager` (using the now synced time for checkups) - `dispatchers.ConnectivityManager.ConnectivityManager`: fixing `_checkDispatcherHealth` - Fixing `extractUniqueValues` now it is possible to use different pathes for the `key` and `value` - `lib\helpers\mapMethods.ts` has been adapted
52 lines
1.0 KiB
TypeScript
52 lines
1.0 KiB
TypeScript
/**
|
|
* @author Martin Karkowski
|
|
* @email m.karkowski@zema.de
|
|
*/
|
|
|
|
import { BehaviorSubject, ReplaySubject, Subject } from "rxjs";
|
|
|
|
export interface TSubjectOptions {
|
|
/**
|
|
* Definition whether to show the current value on subscription.
|
|
*
|
|
* @author M.Karkowski
|
|
* @type {boolean}
|
|
* @memberof TSubjectOptions
|
|
*/
|
|
showCurrent?: boolean;
|
|
|
|
/**
|
|
* Definition, whether to playback the history every
|
|
* time or not.
|
|
*
|
|
* @author M.Karkowski
|
|
* @type {boolean}
|
|
* @memberof TSubjectOptions
|
|
*/
|
|
playHistory?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Helper to define the correct RXJS Subject.
|
|
*
|
|
* @author M.Karkowski
|
|
* @export
|
|
* @template T
|
|
* @param {{
|
|
* useHistory?: boolean,
|
|
* playBackhistoryEveryTime?: boolean;
|
|
* }} [options={}]
|
|
* @return {*}
|
|
*/
|
|
export function getSubject<T>(
|
|
options: TSubjectOptions = {}
|
|
): Subject<T> | ReplaySubject<T> | BehaviorSubject<T> {
|
|
if (options.showCurrent) {
|
|
if (options.playHistory) {
|
|
return new ReplaySubject<T>();
|
|
}
|
|
return new BehaviorSubject<T>(undefined);
|
|
}
|
|
return new Subject<T>();
|
|
}
|