feat(openapi): Add modified typescript-fetch template
This template is modified from the original one, to handle multiple status-code handling of response. Don't ask me how they work, I don't quite understand them in depth...
This commit is contained in:
parent
b7c2a3dff9
commit
5dd6067c95
32 changed files with 2852 additions and 0 deletions
21
openapi-template/ApiEntitiesReducer.mustache
Normal file
21
openapi-template/ApiEntitiesReducer.mustache
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import {ApiEntitiesRecord} from "./ApiEntitiesRecord{{importFileExtension}}";
|
||||
import {ReducerBuilder} from "redux-ts-simple";
|
||||
import {normalizedEntities} from "./runtimeSagasAndRecords{{importFileExtension}}";
|
||||
|
||||
export const ApiEntitiesReducer = new ReducerBuilder(ApiEntitiesRecord())
|
||||
.on(normalizedEntities, (state, action): ApiEntitiesRecord => {
|
||||
const {entities} = action.payload;
|
||||
return state.withMutations(mutableState => {
|
||||
for (const entityKey in entities) {
|
||||
const entityMap = entities[entityKey];
|
||||
const currentEntityMap = mutableState.get(entityKey as any);
|
||||
if (currentEntityMap) {
|
||||
let mergedEntityMap = currentEntityMap.mergeDeep(entityMap);
|
||||
if (!mergedEntityMap.equals(currentEntityMap)) {
|
||||
mutableState.set(entityKey as any, mergedEntityMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
})
|
||||
.build();
|
||||
Loading…
Add table
Add a link
Reference in a new issue