Add redux to 0x instant
This commit is contained in:
		@@ -64,6 +64,8 @@
 | 
			
		||||
        "@types/node": "*",
 | 
			
		||||
        "@types/react": "16.4.7",
 | 
			
		||||
        "@types/react-dom": "^16.0.8",
 | 
			
		||||
        "@types/react-redux": "^6.0.9",
 | 
			
		||||
        "@types/redux": "^3.6.0",
 | 
			
		||||
        "awesome-typescript-loader": "^5.2.1",
 | 
			
		||||
        "copyfiles": "^1.2.0",
 | 
			
		||||
        "enzyme": "^3.6.0",
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,15 @@
 | 
			
		||||
import * as React from 'react';
 | 
			
		||||
import { Provider } from 'react-redux';
 | 
			
		||||
 | 
			
		||||
import { ThemeProvider } from '../style/theme';
 | 
			
		||||
import { store } from '../redux/store';
 | 
			
		||||
import { theme, ThemeProvider } from '../style/theme';
 | 
			
		||||
 | 
			
		||||
export interface ZeroExInstantProps {}
 | 
			
		||||
 | 
			
		||||
export const ZeroExInstant: React.StatelessComponent<ZeroExInstantProps> = () => (
 | 
			
		||||
    <ThemeProvider>
 | 
			
		||||
        <div> ZeroExInstant </div>
 | 
			
		||||
    </ThemeProvider>
 | 
			
		||||
    <Provider store={store}>
 | 
			
		||||
        <ThemeProvider theme={theme}>
 | 
			
		||||
            <div> ZeroExInstant </div>
 | 
			
		||||
        </ThemeProvider>
 | 
			
		||||
    </Provider>
 | 
			
		||||
);
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										23
									
								
								packages/instant/src/redux/reducer.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								packages/instant/src/redux/reducer.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,23 @@
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
 | 
			
		||||
import { Action, ActionTypes } from '../types';
 | 
			
		||||
 | 
			
		||||
export interface State {
 | 
			
		||||
    ethUsdPrice?: string;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export const INITIAL_STATE: State = {
 | 
			
		||||
    ethUsdPrice: undefined,
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export function reducer(state: State = INITIAL_STATE, action: Action): State {
 | 
			
		||||
    switch (action.type) {
 | 
			
		||||
        case ActionTypes.UPDATE_ETH_USD_PRICE:
 | 
			
		||||
            return {
 | 
			
		||||
                ...state,
 | 
			
		||||
                ethUsdPrice: action.data,
 | 
			
		||||
            };
 | 
			
		||||
        default:
 | 
			
		||||
            return state;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										8
									
								
								packages/instant/src/redux/store.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								packages/instant/src/redux/store.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
import * as _ from 'lodash';
 | 
			
		||||
import { applyMiddleware, createStore, Store as ReduxStore } from 'redux';
 | 
			
		||||
 | 
			
		||||
import { reducer, State } from './reducer';
 | 
			
		||||
 | 
			
		||||
const ONE_SECOND = 1000;
 | 
			
		||||
 | 
			
		||||
export const store: ReduxStore<State> = createStore(reducer);
 | 
			
		||||
							
								
								
									
										8
									
								
								packages/instant/src/types.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										8
									
								
								packages/instant/src/types.ts
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,8 @@
 | 
			
		||||
export enum ActionTypes {
 | 
			
		||||
    UPDATE_ETH_USD_PRICE,
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export interface Action {
 | 
			
		||||
    type: ActionTypes;
 | 
			
		||||
    data?: any;
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										33
									
								
								yarn.lock
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								yarn.lock
									
									
									
									
									
								
							@@ -1223,6 +1223,13 @@
 | 
			
		||||
    "@types/react" "*"
 | 
			
		||||
    redux "^3.6.0"
 | 
			
		||||
 | 
			
		||||
"@types/react-redux@^6.0.9":
 | 
			
		||||
  version "6.0.9"
 | 
			
		||||
  resolved "http://localhost:4873/@types%2freact-redux/-/react-redux-6.0.9.tgz#96aa7f5b0716bcc3bfb36ceaa1223118d509f79a"
 | 
			
		||||
  dependencies:
 | 
			
		||||
    "@types/react" "*"
 | 
			
		||||
    redux "^4.0.0"
 | 
			
		||||
 | 
			
		||||
"@types/react-router-dom@^4.0.4":
 | 
			
		||||
  version "4.2.6"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/@types/react-router-dom/-/react-router-dom-4.2.6.tgz#9f7eb3c0e6661a9607d878ff8675cc4ea95cd276"
 | 
			
		||||
@@ -1275,7 +1282,7 @@
 | 
			
		||||
 | 
			
		||||
"@types/redux@^3.6.0":
 | 
			
		||||
  version "3.6.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/@types/redux/-/redux-3.6.0.tgz#f1ebe1e5411518072e4fdfca5c76e16e74c1399a"
 | 
			
		||||
  resolved "http://localhost:4873/@types%2fredux/-/redux-3.6.0.tgz#f1ebe1e5411518072e4fdfca5c76e16e74c1399a"
 | 
			
		||||
  dependencies:
 | 
			
		||||
    redux "*"
 | 
			
		||||
 | 
			
		||||
@@ -12731,18 +12738,7 @@ react-popper@^1.0.0-beta.6:
 | 
			
		||||
    typed-styles "^0.0.5"
 | 
			
		||||
    warning "^3.0.0"
 | 
			
		||||
 | 
			
		||||
react-redux@^5.0.3:
 | 
			
		||||
  version "5.0.7"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.7.tgz#0dc1076d9afb4670f993ffaef44b8f8c1155a4c8"
 | 
			
		||||
  dependencies:
 | 
			
		||||
    hoist-non-react-statics "^2.5.0"
 | 
			
		||||
    invariant "^2.0.0"
 | 
			
		||||
    lodash "^4.17.5"
 | 
			
		||||
    lodash-es "^4.17.5"
 | 
			
		||||
    loose-envify "^1.1.0"
 | 
			
		||||
    prop-types "^15.6.0"
 | 
			
		||||
 | 
			
		||||
react-redux@^5.0.7:
 | 
			
		||||
react-redux@^5.0.3, react-redux@^5.0.7:
 | 
			
		||||
  version "5.0.7"
 | 
			
		||||
  resolved "http://localhost:4873/react-redux/-/react-redux-5.0.7.tgz#0dc1076d9afb4670f993ffaef44b8f8c1155a4c8"
 | 
			
		||||
  dependencies:
 | 
			
		||||
@@ -13121,9 +13117,9 @@ redux-devtools-extension@^2.13.2:
 | 
			
		||||
  version "2.13.2"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/redux-devtools-extension/-/redux-devtools-extension-2.13.2.tgz#e0f9a8e8dfca7c17be92c7124958a3b94eb2911d"
 | 
			
		||||
 | 
			
		||||
redux@*:
 | 
			
		||||
redux@*, redux@^4.0.0:
 | 
			
		||||
  version "4.0.0"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/redux/-/redux-4.0.0.tgz#aa698a92b729315d22b34a0553d7e6533555cc03"
 | 
			
		||||
  resolved "http://localhost:4873/redux/-/redux-4.0.0.tgz#aa698a92b729315d22b34a0553d7e6533555cc03"
 | 
			
		||||
  dependencies:
 | 
			
		||||
    loose-envify "^1.1.0"
 | 
			
		||||
    symbol-observable "^1.2.0"
 | 
			
		||||
@@ -13137,13 +13133,6 @@ redux@^3.6.0:
 | 
			
		||||
    loose-envify "^1.1.0"
 | 
			
		||||
    symbol-observable "^1.0.3"
 | 
			
		||||
 | 
			
		||||
redux@^4.0.0:
 | 
			
		||||
  version "4.0.0"
 | 
			
		||||
  resolved "http://localhost:4873/redux/-/redux-4.0.0.tgz#aa698a92b729315d22b34a0553d7e6533555cc03"
 | 
			
		||||
  dependencies:
 | 
			
		||||
    loose-envify "^1.1.0"
 | 
			
		||||
    symbol-observable "^1.2.0"
 | 
			
		||||
 | 
			
		||||
regenerate@^1.2.1:
 | 
			
		||||
  version "1.3.3"
 | 
			
		||||
  resolved "https://registry.yarnpkg.com/regenerate/-/regenerate-1.3.3.tgz#0c336d3980553d755c39b586ae3b20aa49c82b7f"
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user