Skip to content

Commit 9d50df8

Browse files
committed
feat(rx-stateful): consider keepErrorOnRefresh configuration
1 parent 2a85322 commit 9d50df8

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

libs/rx-stateful/src/lib/util/calc-start-value-for-refresh.spec.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,16 @@ describe('calcStartValueForRefresh', () => {
1313
expect(result).toHaveProperty('value', null);
1414
});
1515
});
16+
describe('keepErrorOnRefresh ', () => {
17+
it('should return without error property when keepErrorOnRefresh = true', () => {
18+
const result = calcStartValueForRefresh({ keepErrorOnRefresh: true });
19+
20+
expect(result).not.toHaveProperty('error');
21+
});
22+
it('should return with property error = undefined when keepErrorOnRefresh = false', () => {
23+
const result = calcStartValueForRefresh({ keepErrorOnRefresh: false });
24+
25+
expect(result).toHaveProperty('error', undefined);
26+
});
27+
});
1628
});
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
import {InternalRxState, RxStatefulConfig} from "../types/types";
22

33
export function calcStartValueForRefresh<T, E>(mergedConfig: RxStatefulConfig<T,E>): Partial<InternalRxState<T, E>>{
4-
let baseStartWithValue: Partial<InternalRxState<T, E>> = { isLoading: true, isRefreshing: true, context: 'suspense', error: undefined };
4+
let baseStartWithValue: Partial<InternalRxState<T, E>> = { isLoading: true, isRefreshing: true, context: 'suspense'};
55
if (!mergedConfig?.keepValueOnRefresh) {
66
baseStartWithValue = { ...baseStartWithValue, value: null };
77
}
8+
if(!mergedConfig?.keepErrorOnRefresh) {
9+
baseStartWithValue = { ...baseStartWithValue, error: undefined };
10+
}
811

912
return baseStartWithValue;
1013
}

0 commit comments

Comments
 (0)