new subjects
This commit is contained in:
19
src/Umbraco.Web.UI.Client/libs/observable-api/basic-state.ts
Normal file
19
src/Umbraco.Web.UI.Client/libs/observable-api/basic-state.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { BehaviorSubject } from "rxjs";
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class BasicState
|
||||
* @extends {BehaviorSubject<T>}
|
||||
* @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
|
||||
*/
|
||||
export class BasicState<T extends string | number | undefined | null> extends BehaviorSubject<T> {
|
||||
constructor(initialData: T) {
|
||||
super(initialData);
|
||||
}
|
||||
|
||||
next(newData: T): void {
|
||||
if(newData !== this.getValue()) {
|
||||
super.next(newData);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { BasicState } from "./basic-state";
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class NumberState
|
||||
* @extends {BehaviorSubject<T>}
|
||||
* @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
|
||||
*/
|
||||
export class NumberState<T extends number | undefined | null> extends BasicState<T> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import { BasicState } from "./basic-state";
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class StringState
|
||||
* @extends {BehaviorSubject<T>}
|
||||
* @description - A RxJS BehaviorSubject this Subject ensures the data is unique, not updating any Observes unless there is an actual change of the value.
|
||||
*/
|
||||
export class StringState<T extends string | undefined | null> extends BasicState<T> {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user