rest-hooks
Advanced tools
Comparing version 0.3.0 to 0.3.1
import Resource, { SelectShape as ImportedSelectShape } from './resource/Resource'; | ||
import { RestProvider, hooks } from './connect'; | ||
import { RestProvider, hooks } from './react-rest'; | ||
import * as selectors from './state/selectors'; | ||
export declare type SelectShape<T extends typeof Resource, S> = ImportedSelectShape<T, S>; | ||
export { Resource, RestProvider, hooks, selectors }; |
import Resource from './resource/Resource'; | ||
import { RestProvider, hooks } from './connect'; | ||
import { RestProvider, hooks } from './react-rest'; | ||
import * as selectors from './state/selectors'; // this is required so babel doesn't put the export in the JS code | ||
export { Resource, RestProvider, hooks, selectors }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uL3NyYy9pbmRleC50cyJdLCJuYW1lcyI6WyJSZXNvdXJjZSIsIlJlc3RQcm92aWRlciIsImhvb2tzIiwic2VsZWN0b3JzIl0sIm1hcHBpbmdzIjoiQUFBQSxPQUFPQSxRQUFQLE1BQTZELHFCQUE3RDtBQUNBLFNBQVNDLFlBQVQsRUFBdUJDLEtBQXZCLFFBQW9DLFdBQXBDO0FBQ0EsT0FBTyxLQUFLQyxTQUFaLE1BQTJCLG1CQUEzQixDLENBRUE7O0FBRUEsU0FBU0gsUUFBVCxFQUFtQkMsWUFBbkIsRUFBaUNDLEtBQWpDLEVBQXdDQyxTQUF4QyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCBSZXNvdXJjZSwgeyBTZWxlY3RTaGFwZSBhcyBJbXBvcnRlZFNlbGVjdFNoYXBlIH0gZnJvbSAnLi9yZXNvdXJjZS9SZXNvdXJjZSc7XG5pbXBvcnQgeyBSZXN0UHJvdmlkZXIsIGhvb2tzIH0gZnJvbSAnLi9jb25uZWN0JztcbmltcG9ydCAqIGFzIHNlbGVjdG9ycyBmcm9tICcuL3N0YXRlL3NlbGVjdG9ycyc7XG5cbi8vIHRoaXMgaXMgcmVxdWlyZWQgc28gYmFiZWwgZG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lbmRzIHR5cGVvZiBSZXNvdXJjZSwgUz4gPSBJbXBvcnRlZFNlbGVjdFNoYXBlPFQsIFM+O1xuZXhwb3J0IHsgUmVzb3VyY2UsIFJlc3RQcm92aWRlciwgaG9va3MsIHNlbGVjdG9ycyB9O1xuIl19 |
import { Resource } from '../resource'; | ||
import { ReceiveAction, State } from '../types'; | ||
declare type ActionTypes = ReceiveAction; | ||
import { ActionTypes, State } from '../types'; | ||
export default function reducer(state: State<Resource>, action: ActionTypes): { | ||
@@ -9,3 +8,5 @@ entities: any; | ||
}; | ||
meta: { | ||
[url: string]: any; | ||
}; | ||
}; | ||
export {}; |
@@ -20,5 +20,13 @@ import "core-js/modules/es6.array.for-each"; | ||
entities: _merge(_objectSpread({}, state.entities), normalized.entities), | ||
results: _objectSpread({}, state.results, _defineProperty({}, action.meta.url, normalized.result)) | ||
results: _objectSpread({}, state.results, _defineProperty({}, action.meta.url, normalized.result)), | ||
meta: state.meta | ||
}; | ||
case 'fetch': | ||
return _objectSpread({}, state, { | ||
meta: _objectSpread({}, state.meta, _defineProperty({}, action.payload, _objectSpread({}, action.meta, { | ||
status: 'fetching' | ||
}))) | ||
}); | ||
default: | ||
@@ -30,2 +38,2 @@ // A reducer must always return a valid state. | ||
} | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9zdGF0ZS9yZWR1Y2VyLnRzIl0sIm5hbWVzIjpbIm5vcm1hbGl6ZSIsInJlZHVjZXIiLCJzdGF0ZSIsImFjdGlvbiIsInR5cGUiLCJub3JtYWxpemVkIiwicGF5bG9hZCIsIm1ldGEiLCJzY2hlbWEiLCJlbnRpdGllcyIsInJlc3VsdHMiLCJ1cmwiLCJyZXN1bHQiXSwibWFwcGluZ3MiOiI7Ozs7Ozs7Ozs7OztBQUFBLFNBQVNBLFNBQVQsUUFBMEIsV0FBMUI7QUFPQSxlQUFlLFNBQVNDLE9BQVQsQ0FD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0aW9uOiBBY3Rpb25UeXBlcykge1xuICBzd2l0Y2ggKGFjdGlvbi50eXBlKSB7XG4gICAgY2FzZSAncmVjZWl2ZSc6XG4gICAgICBjb25zdCBub3JtYWxpemVkID0gbm9ybWFsaXplKGFjdGlvbi5wYXlsb2FkLCBhY3Rpb24ubWV0YS5zY2hlbWEpO1xuICAgICAgcmV0dXJuIHtcbiAgICAgICAgZW50aXRpZXM6IG1lcmdlKHsgLi4uc3RhdGUuZW50aXRpZXMgfSwgbm9ybWFsaXplZC5lbnRpdGllcyksXG4gICAgICAgIHJlc3VsdHM6IHtcbiAgICAgICAgICAuLi5zdGF0ZS5yZXN1bHRzLFxuICAgICAgICAgIFthY3Rpb24ubWV0YS51cmxdOiBub3JtYWxpemVkLnJlc3VsdCxcbiAgICAgICAgfSxcbiAgICAgICAgbWV0YTogc3RhdGUubWV0YSxcbiAgICAgIH07XG4gICAgY2FzZSAnZmV0Y2gnOlxuICAgICAgcmV0dXJuIHtcbiAgICAgICAgLi4uc3RhdGUsXG4gICAgICAgIG1ldGE6IHtcbiAgICAgICAgICAuLi5zdGF0ZS5tZXRhLFxuICAgICAgICAgIFthY3Rpb24ucGF5bG9hZF06IHtcbiAgICAgICAgICAgIC4uLmFjdGlvbi5tZXRhLFxuICAgICAgICAgICAgc3RhdHVzOiAnZmV0Y2hpbmcnLFxuICAgICAgICAgIH0sXG4gICAgICAgIH0sXG4gICAgICB9O1xuICAgIGRlZmF1bHQ6XG4gICAgICAvLyBBIHJlZHVjZXIgbXVzdCBhbHdheXMgcmV0dXJuIGEgdmFsaWQgc3RhdGUuXG4gICAgICAvLyBBbHRlcm5hdGl2ZWx5IHlvdSBjYW4gdGhyb3cgYW4gZXJyb3IgaWYgYW4gaW52YWxpZCBhY3Rpb24gaXMgZGlzcGF0Y2hlZC5cbiAgICAgIHJldHVybiBzdGF0ZTtcbiAgfVxufVxuIl19 |
@@ -17,2 +17,5 @@ import { FSA } from 'flux-standard-action'; | ||
}; | ||
meta: { | ||
[url: string]: any; | ||
}; | ||
}; | ||
@@ -26,1 +29,11 @@ export interface ReceiveAction extends FSA<any, any> { | ||
} | ||
export interface FetchAction extends FSA<any, any> { | ||
type: 'fetch'; | ||
payload: string; | ||
meta: { | ||
schema: Schema; | ||
promise: Promise<any>; | ||
date: number; | ||
}; | ||
} | ||
export declare type ActionTypes = ReceiveAction | FetchAction; |
{ | ||
"name": "rest-hooks", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Easy react hooks for REST apis", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
80045
646
2