@equinor/fusion-observable
Advanced tools
Comparing version 8.3.3 to 8.4.0
@@ -14,3 +14,3 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) { | ||
import { asyncScheduler, BehaviorSubject, EMPTY, from, Observable, Subject, } from 'rxjs'; | ||
import { catchError, distinctUntilChanged, filter, mergeMap, observeOn, scan, } from 'rxjs/operators'; | ||
import { catchError, distinctUntilChanged, filter, map, mergeMap, observeOn, scan, } from 'rxjs/operators'; | ||
import { filterAction } from './operators'; | ||
@@ -75,2 +75,12 @@ /** | ||
/** | ||
* Selects a derived state from the observable state and emits only when the selected state changes. | ||
* | ||
* @param selector - A function that takes the current state and returns a derived state. | ||
* @param comparator - An optional function that compares the previous and current derived states to determine if a change has occurred. | ||
* @returns An observable that emits the derived state whenever it changes. | ||
*/ | ||
select(selector, comparator) { | ||
return __classPrivateFieldGet(this, _FlowSubject_state, "f").pipe(map(selector), distinctUntilChanged(comparator)); | ||
} | ||
/** | ||
* Adds an effect that listens for actions and performs side effects. | ||
@@ -77,0 +87,0 @@ * |
// Generated by genversion. | ||
export const version = '8.3.3'; | ||
export const version = '8.4.0'; | ||
//# sourceMappingURL=version.js.map |
@@ -26,9 +26,13 @@ import { Reducer } from 'react'; | ||
/** | ||
* Initializes a new instance of the FlowSubject class. | ||
* | ||
* Creates a new instance of the FlowSubject class with an initial state reducer. | ||
* @param reducer A reducer with an initial state or a reducer function. | ||
* @param initialState The initial state of the subject. | ||
*/ | ||
constructor(reducer: ReducerWithInitialState<S, A> | Reducer<S, A>, initialState?: S); | ||
constructor(reducer: ReducerWithInitialState<S, A>); | ||
/** | ||
* Create a new instance of the FlowSubject class with a reducer function and initial state. | ||
* @param reducer state reducer | ||
* @param initialState initial state | ||
*/ | ||
constructor(reducer: Reducer<S, A>, initialState: S); | ||
/** | ||
* Resets the state to the initial value. | ||
@@ -44,2 +48,10 @@ */ | ||
/** | ||
* Selects a derived state from the observable state and emits only when the selected state changes. | ||
* | ||
* @param selector - A function that takes the current state and returns a derived state. | ||
* @param comparator - An optional function that compares the previous and current derived states to determine if a change has occurred. | ||
* @returns An observable that emits the derived state whenever it changes. | ||
*/ | ||
select<T>(selector: (state: S) => T, comparator?: (previous: T, current: T) => boolean): Observable<T>; | ||
/** | ||
* Adds an effect that listens for actions and performs side effects. | ||
@@ -46,0 +58,0 @@ * |
@@ -120,3 +120,3 @@ export type TypeConstant = string; | ||
*/ | ||
export type ActionBaseType<TAction extends Action> = TAction extends Action ? TAction['type'] extends `${infer AName}::${infer ASuffix}` ? AName : TAction['type'] : never; | ||
export type ActionBaseType<TAction extends Action> = TAction extends Action ? Extract<TAction['type'] extends `${infer AName}::${infer ASuffix}` ? AName : TAction['type'], string> : never; | ||
/** | ||
@@ -123,0 +123,0 @@ * Utility type that extracts the payload type from an `ActionInstance` type. |
@@ -1,1 +0,1 @@ | ||
export declare const version = "8.3.3"; | ||
export declare const version = "8.4.0"; |
{ | ||
"name": "@equinor/fusion-observable", | ||
"version": "8.3.3", | ||
"version": "8.4.0", | ||
"description": "WIP", | ||
@@ -62,3 +62,3 @@ "keywords": [ | ||
"devDependencies": { | ||
"@testing-library/react": "^15.0.7", | ||
"@testing-library/react": "^16.0.0", | ||
"@types/node": "^20.11.14", | ||
@@ -70,3 +70,3 @@ "@types/react": "^18.2.50", | ||
"typescript": "^5.5.3", | ||
"vitest": "^2.0.1" | ||
"vitest": "^2.0.5" | ||
}, | ||
@@ -73,0 +73,0 @@ "peerDependencies": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176875
1465