redux-saga-resources
Advanced tools
Comparing version 0.1.7 to 0.1.10
@@ -46,3 +46,3 @@ import { EmptyActionCreator, ActionCreator } from 'redux-typescript-actions'; | ||
item(state: any): T; | ||
sourceItems(state: any): T; | ||
sourceItems(state: any): T[]; | ||
} | ||
@@ -49,0 +49,0 @@ export interface IBatchMerger<T> { |
@@ -6,4 +6,4 @@ export default function selectors<T>(name: any, options: any, resource: any): { | ||
deleting: (state: any) => any; | ||
sourceItems: (state: any) => T; | ||
sourceItems: (state: any) => T[]; | ||
item: (state: any) => T; | ||
}; |
@@ -179,2 +179,13 @@ "use strict"; | ||
exports.restMiddleware = restMiddleware; | ||
function* safeFetch(url, options) { | ||
try { | ||
return yield effects_1.call(() => fetch(url, options)); | ||
} | ||
catch (ex) { | ||
return { | ||
statusText: 'error', | ||
statusCode: 0 | ||
}; | ||
} | ||
} | ||
function* fetchMiddleware({ request, response, withResponse }, next) { | ||
@@ -185,3 +196,3 @@ const paramKeys = Object.keys(request.params); | ||
const url = params ? `${baseUrl}?${params}` : baseUrl; | ||
const result = yield effects_1.call(() => fetch(url, { | ||
const result = yield safeFetch(url, { | ||
method: request.method, | ||
@@ -191,3 +202,3 @@ headers: request.headers, | ||
body: request.body | ||
})); | ||
}); | ||
response.statusText = result.statusText; | ||
@@ -194,0 +205,0 @@ response.statusCode = result.status; |
{ | ||
"name": "redux-saga-resources", | ||
"version": "0.1.7", | ||
"version": "0.1.10", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "typings": "es6/index.d.ts", |
@@ -34,3 +34,3 @@ import actionCreatorFactory, { EmptyActionCreator, ActionCreator } from 'redux-typescript-actions'; | ||
item(state): T; | ||
sourceItems(state): T; | ||
sourceItems(state): T[]; | ||
} | ||
@@ -37,0 +37,0 @@ export interface IBatchMerger<T> { |
@@ -15,5 +15,5 @@ import { internal } from '../utils/internal'; | ||
deleting: (state) => scope(state).deleting, | ||
sourceItems: (state): T => scope(state).items, | ||
sourceItems: (state): T[] => scope(state).items, | ||
item: (state): T => scope(state).item | ||
} | ||
} |
@@ -198,2 +198,12 @@ import * as fetch from 'isomorphic-fetch'; | ||
} | ||
function* safeFetch(url, options) { | ||
try { | ||
return yield call(() => fetch(url, options)) as any; | ||
} catch(ex) { | ||
return { | ||
statusText: 'error', | ||
statusCode: 0 | ||
}; | ||
} | ||
} | ||
export function* fetchMiddleware({ request, response, withResponse }, next) { | ||
@@ -205,3 +215,3 @@ const paramKeys = Object.keys(request.params); | ||
const result = yield call(() => fetch(url, { | ||
const result = yield safeFetch(url, { | ||
method: request.method, | ||
@@ -211,3 +221,3 @@ headers: request.headers, | ||
body: request.body | ||
})) as any; | ||
}) as any; | ||
@@ -214,0 +224,0 @@ response.statusText = result.statusText; |
Sorry, the diff of this file is not supported yet
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
286931
4325