Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion libs/rx-stateful/src/lib/create-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ function handleError<T, E>(
error$$: Subject<RxStatefulWithError<T, E>>
) {
mergedConfig?.beforeHandleErrorFn?.(error);
const errorMappingFn = mergedConfig.errorMappingFn ?? ((error: E) => error as any);
const errorMappingFn = mergedConfig.errorMappingFn ?? ((error: E) => error);
error$$.next({ error: errorMappingFn(error), context: 'error', isLoading: false, isRefreshing: false, value: null });
return NEVER;
}
Expand Down
30 changes: 14 additions & 16 deletions libs/rx-stateful/src/lib/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import {Observable, Subject} from 'rxjs';
import {RxStatefulAccumulationFn} from "./accumulation-fn";
import {RefetchStrategy} from "../refetch-strategies/refetch-strategy";
import {Injector} from "@angular/core";


import { Observable, Subject } from 'rxjs';
import { RxStatefulAccumulationFn } from './accumulation-fn';
import { RefetchStrategy } from '../refetch-strategies/refetch-strategy';
import { Injector } from '@angular/core';

/**
* @publicApi
*
* @description
* Context of the current emission.
*/
export type RxStatefulContext = 'suspense' | 'error' | 'next';


export type RxStatefulContext = 'suspense' | 'error' | 'next';

/**
* @publicApi
Expand All @@ -30,8 +26,10 @@ export interface RxStateful<T, E = unknown> {
hasValue: boolean;
}


export type RxStatefulWithError<T, E = unknown> = Pick<InternalRxState<T, E>, 'error' | 'context' | 'isLoading' | 'isRefreshing' | 'value' >;
export type RxStatefulWithError<T, E = unknown> = Pick<
InternalRxState<T, E>,
'error' | 'context' | 'isLoading' | 'isRefreshing' | 'value'
>;

/**
* @internal
Expand All @@ -57,7 +55,7 @@ export interface RxStatefulConfig<T, E = unknown> {
/**
* One or multiple Trigger to refresh the source$.
*/
refetchStrategies?: RefetchStrategy[] | RefetchStrategy
refetchStrategies?: RefetchStrategy[] | RefetchStrategy;
/**
* Define if the value should be kept on refresh or reset to null
* @default false
Expand All @@ -78,7 +76,7 @@ export interface RxStatefulConfig<T, E = unknown> {
* Mapping function to map the error to a specific value.
* @param error - the error which is thrown by the source$, e.g. a {@link HttpErrorResponse}.
*/
errorMappingFn?: (error: E) => unknown;
errorMappingFn?: (error: E) => E;
/**
* Function which is called before the error is handled.
* @param error - the error which is thrown by the source$, e.g. a {@link HttpErrorResponse}.
Expand Down Expand Up @@ -107,12 +105,12 @@ export interface SourceTriggerConfig<A> {
operator?: 'switch' | 'merge' | 'concat' | 'exhaust';
}

export type RxStatefulSourceTriggerConfig<T,A, E = unknown> = RxStatefulConfig<T, E> &{
export type RxStatefulSourceTriggerConfig<T, A, E = unknown> = RxStatefulConfig<T, E> & {
/**
*
*/
sourceTriggerConfig: SourceTriggerConfig<A>
}
sourceTriggerConfig: SourceTriggerConfig<A>;
};

/**
* @publicApi
Expand Down
Loading