Skip to content

Instantly share code, notes, and snippets.

View georg3103's full-sized avatar
💭
What's happening?

George georg3103

💭
What's happening?
View GitHub Profile
@georg3103
georg3103 / machine.js
Last active July 24, 2021 13:30
Generated by XState Viz: https://xstate.js.org/viz
const videoRecorderMachine = Machine({
// not a parallel machine
id: 'videoRecorder',
context: {
interval: 1,
elapsed: 0,
elapsed1: 0,
elapsed2: 0,
duration: 3,
duration1: 4,
const thunk = (store) => (next) => (action) => {
if (typeof action === 'function') {
return action(store.dispatch)
}
return next(action)
}
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())
}
@georg3103
georg3103 / slow.js
Last active April 15, 2019 00:08
Helper Functions
export function throttle(func, ms) {
let isThrottled = false,
savedArgs,
savedThis;
function wrapper(...args) {
// memorize all func calls
if (isThrottled) {