Skip to content

Commit

Permalink
Remove aliases and use actions creators
Browse files Browse the repository at this point in the history
  • Loading branch information
amitmbee committed May 2, 2018
1 parent 6c2b626 commit 3e6ebe8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 36 deletions.
26 changes: 20 additions & 6 deletions app/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,29 @@ export function sendMessageToUI(message:string){
export function updateInterceptorStatus(tabId:number, value:boolean){
return {type : UPDATE_INTERCEPTOR_STATUS, payload : {tabId, value}}
}
export function fetchResponse(requestDetails:object) {
return {
type: FETCH_DATA,
requestDetails
}
}
export function fetchSuccess(data:object, requestId:number){
return {type: FETCH_DATA_SUCCESS, payload : {response : data.data, requestId } }
}
export function fetchFailure(error:object, requestId:number){
return {type : FETCH_DATA_FAILURE, payload : {error : error.data, requestId } }
}
export function fetchResponse(payload: object) {
const {method, url, requestId, requestHeaders} = payload.requestDetails;
const requestHeadersObject = requestHeaders.reduce((accumulatedObj, reqHeaderNameValuePair) => {
accumulatedObj[reqHeaderNameValuePair.name] = reqHeaderNameValuePair.value;
return accumulatedObj;
}, {});
return (dispatch) => {
axios({
method,
url,
requestHeadersObject
})
.then(data => {
dispatch(fetchSuccess(data, requestId));
})
.catch(err => {
dispatch(fetchFailure(err, requestId));
});
};
};
27 changes: 0 additions & 27 deletions app/store/aliases.ts

This file was deleted.

3 changes: 0 additions & 3 deletions app/store/popup_store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ import { createStore, applyMiddleware } from 'redux'
import { createLogger } from 'redux-logger'
import { Middleware } from 'react-redux/node_modules/redux';
import thunkMiddleware from 'redux-thunk';
import aliases from './aliases'
import { alias } from 'react-chrome-redux';

import {reducer} from './../reducers/rootReducer';
export interface PopUpInterface {
Expand All @@ -18,7 +16,6 @@ const logger:Middleware = createLogger({
})

enhancer = applyMiddleware(
alias(aliases),
thunkMiddleware,
logger
);
Expand Down

0 comments on commit 3e6ebe8

Please sign in to comment.