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
export function throttle(func, ms) { | |
let isThrottled = false, | |
savedArgs, | |
savedThis; | |
function wrapper(...args) { | |
// memorize all func calls | |
if (isThrottled) { |
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
const Context = React.createContext() | |
function connect (mapStateToProps) { | |
return (Component) => { | |
class Receiver extends React.Component { | |
componentDidMount() { | |
const { subscribe } = this.props.store | |
this.unsubcribe = subscribe(() => this.forceUpdate()) | |
} |
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
const thunk = (store) => (next) => (action) => { | |
if (typeof action === 'function') { | |
return action(store.dispatch) | |
} | |
return next(action) | |
} |
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
const videoRecorderMachine = Machine({ | |
// not a parallel machine | |
id: 'videoRecorder', | |
context: { | |
interval: 1, | |
elapsed: 0, | |
elapsed1: 0, | |
elapsed2: 0, | |
duration: 3, | |
duration1: 4, |