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
class Family extends React.Component { | |
state = { funds: 100 } | |
render () { | |
return <Dad name={this.state.funds}/> | |
} | |
} | |
class Dad extends React.Component { | |
render () { |
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 actionTypeSpendInit = 'SPEND_INIT' | |
const actionTypeSpendSuccess = 'SPEND_SUCCESS' | |
const actionTypeSpendError = 'SPEND_ERROR' | |
class ActionSpendInit { | |
type = actionTypeSpendInit | |
constructor(public payload) | |
} | |
class ActionSpendSuccess { | |
type = actionTypeSpendSuccess |
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
# don't ever lint node_modules | |
node_modules | |
# don't lint build output (make sure it's set to your correct build folder name) | |
dist | |
# don't lint nyc coverage output | |
coverage |
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 reducerLoading = (actionInit, actionSuccess, actionError) => ( | |
state = false, | |
action, | |
) => { | |
switch (action.type) { | |
case actionInit.type: | |
return true | |
case actionSuccess.type: | |
return false | |
case actionError.type: |
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
class CatsGetInit extends ActionStandard {} | |
class CatsGetSuccess extends ActionStandard {} | |
class CatsGetError extends ActionStandard {} | |
const reducerCatsLoading = createReducer( | |
false, | |
reducerLoadingMap(CatsGetInit, CatsGetSuccess, CatsGetError), | |
) | |
const reducerCatsData = createReducer(undefined, { | |
[CatsGetSuccess.type]: () => action.payload, |
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
class CatsGetInit {} | |
class CatsGetSuccess { | |
constructor(responseData) { | |
this.payload = responseData | |
} | |
} | |
class CatsGetError { | |
constructor(error) { | |
this.payload = error | |
this.error = true |
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
class CatsGetInit { | |
constructor() { | |
this.type = this.constructor.name | |
} | |
} | |
const reducerCats = (state, action) => { | |
switch (action.type) { | |
case CatsGetInit.name: | |
return { | |
...state, |
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
class CatsGetInit { | |
get static type () { | |
return `prefix/${this.name}` | |
} | |
constructor () { | |
this.type = this.constructor.type | |
} | |
} | |
const reducerCats = (state, action) => { | |
switch (action.type) { |
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
class ActionStandard { | |
get static type () { | |
return `prefix/${this.name}` | |
} | |
constructor(payload) { | |
this.type = this.constructor.type | |
this.payload = payload | |
this.error = payload instanceof Error | |
} | |
} |
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
class GlobalErrorInit extends ActionStandard {} | |
class GlobalErrorClear extends ActionStandard {} | |
const reducerError = createReducer(undefined, { | |
[GlobalErrorInit.type]: (state, action) => action.payload, | |
[GlobalErrorClear.type]: (state, action) => undefined, | |
}) |