This file contains 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 { wrapService, withPostSuccess } from 'redux-recompose'; | |
import responseBody from './response'; | |
// Declare your api calls | |
const getCards = async () => new Promise(resolve => setTimeout(() => resolve(responseBody), 1000)); | |
// Declare your customizations, used by fetchMiddleware | |
getCards.successSelector = response => response.cards; | |
getCards.injections = [ |
This file contains 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 React, { Component } from 'react'; | |
import { connect } from 'react-redux'; | |
import SoccerService from '../Services/SoccerService.js'; | |
class MatchList extends Component { | |
componentDidMount() { | |
this.props.dispatch(SoccerService.getMatches()); | |
} | |
This file contains 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 { wrapService } from 'redux-recompose'; | |
import api from '../config/api'; | |
const service = { | |
getMatches: () => api.get('/matches'), | |
getPitches: ({ id }) => api.get('/pitches', { id }), | |
}; | |
export default wrapService(service, 'soccer'); |
This file contains 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 api from '../config/api'; | |
export default { | |
getMatches: () => api.get('/matches'), | |
getPitches: ({ id }) => api.get('/pitches', { id }), | |
}; |
This file contains 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 { createActions, createExternalActions } from 'redux-recompose'; | |
// Our action names, as always. These will be handled by our reducer. | |
export const actions = createActions(['LOCAL_ACTION'], '@@SOCCER'); | |
// External actions names being handled by the invisible reducer. We should specify | |
// what slice of the state is related with this reducer, say, state.soccer | |
// No need to handle them at our reducer. | |
const $ = createExternalActions('soccer'); |
This file contains 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 createReducer from '../../creators/createReducer'; | |
import onLoading from '../../effects/onLoading'; | |
import onSuccess from '../../effects/onSuccess'; | |
import onFailure from '../../effects/onFailure'; | |
// TODO: Let the user specify selectors | |
const reducerDescription = { | |
LOADING: onLoading(), | |
SUCCESS: onSuccess(), | |
FAILURE: onFailure() |
This file contains 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 { combineReducers as CR } from 'redux'; | |
import { wrapCombineReducers } from 'redux-recompose'; | |
const combineReducers = wrapCombineReducers(CR); | |
const rootReducer = combineReducers({ | |
// Add here your reducers like always. | |
}); |
This file contains 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: () => ({ | |
type: actions.GET_MATCHES, | |
target: 'matches', | |
service: SoccerService.getMatches | |
}), |
This file contains 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 | |
}), |
This file contains 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( |
NewerOlder