This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const reducerDescription: { | |
| primaryActions: [actions.GET_MATCHES, actions.GET_PITCHES], | |
| override: { | |
| [actions.INCREMENT_COUNTER]: onAdd() | |
| } | |
| } | |
| export default createReducer(initialState, completeReducer(reducerDescription)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const stateDescription = { | |
| matches: [], | |
| pitches: [], | |
| counter: 0 | |
| }; | |
| const initialState = completeState(stateDescription, ['counter']); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export const actions = createTypes( | |
| completeTypes(['GET_MATCHES', 'GET_PITCHES'], ['INCREMENT_COUNTER']), | |
| '@@SOCCER' | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // if action.payload is like: { matches: [] }; | |
| const reducerDescription = { | |
| // This will store the array of matches instead of the whole object comming from payload | |
| [actions.GET_MATCHES_SUCCESS]: onSuccess(action => action.payload.matches) | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SoccerService from '../services/SoccerService'; | |
| export const actions = createTypes(completeTypes['GET_MATCHES','GET_PITCHES'], '@SOCCER'); | |
| const actionCreators = { | |
| getMatches: () => | |
| createThunkAction(actions.GET_MATCHES, 'matches', SoccerService.getMatches), | |
| getPitches: clubId => | |
| createThunkAction(actions.GET_PITCHES, 'pitches', SoccerService.getPitches, () => clubId) | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const actionCreators = { | |
| fetchSomething: () => async dispatch => { | |
| dispatch({ type: actions.FETCH }); | |
| const response = Service.fetch(); | |
| if (response.ok) { | |
| dispatch({ type: actions.FETCH_SUCCESS, payload: response.data }); | |
| dispatch(navigationActions.push('/successRoute'); | |
| } else { | |
| dispatch({ type: actions.FETCH_ERROR, payload: response.error }); | |
| if (response.status === 404) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const actionCreators = { | |
| fetchSomething: () => composeInjections( | |
| baseThunkAction(actions.FETCH, 'fetchTarget', Service.fetch), | |
| withPostSuccess(dispatch => dispatch(navigationActions.push('/successRoute'))), | |
| withStatusHandling({ 404: dispatch => dispatch(navigationActions.push('/failureRoute')) }) | |
| ) | |
| } | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const reducerDescription: { | |
| [actions.GET_MATCHES]: onLoading(), | |
| [actions.GET_MATCHES_SUCCESS]: onSuccess(), | |
| [actions.GET_MATCHES_FAILURE]: onFailure(), | |
| [actions.GET_PITCHES]: onLoading(), | |
| [actions.GET_PITCHES_SUCCESS]: onSuccess(), | |
| [actions.GET_PITCHES_FAILURE]: onFailure(), | |
| [actions.INCREMENT_COUNTER]: onAdd() | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Taken from https://stackoverflow.com/a/44308018 | |
| from scipy.stats import norm, truncnorm | |
| import matplotlib.pyplot as plt | |
| from numpy import array | |
| from math import pi, cos | |
| SAMPLE_SIZE = 200 | |
| def get_truncated_normal(mean=0, sd=1, low=0, upp=10): | |
| return truncnorm( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import SoccerService from '../services/SoccerService'; | |
| export const actions = createTypes(completeTypes['GET_MATCHES','GET_PITCHES'], '@SOCCER'); | |
| const actionCreators = { | |
| getMatches: () => createThunkAction({ | |
| type: actions.GET_MATCHES, | |
| target: 'matches', | |
| service: SoccerService.getMatches | |
| }), |