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
function pad(num: number) { | |
return `0000${num}`.slice(-2) | |
} | |
function time(hour: number) { | |
return new Date( | |
`Tue Aug 08 2023 ${pad(hour)}:00:00 GMT+0200 (Central European Summer Time)` | |
) | |
} | |
const times = [ |
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 createSelectObservable = (() => { | |
let state; | |
let pReducer = (state, action) => state; | |
const subscribers = new Map(); | |
const addSubscriber = (selector) => { | |
subscribers.set(selector, selector); | |
//return unsubscribe function | |
return () => subscribers.delete(selector); | |
}; | |
const dispatch = (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 REPLACED = 'REPLACED'; | |
const last = (fn) => { | |
const current = { value: {} }; | |
return (...args) => { | |
const now = {}; | |
current.value = now; | |
return Promise.resolve(args) | |
.then((args) => fn(...args)) | |
.then((resolve) => | |
current.value === now |
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
<!-- begin snippet: js hide: false console: true babel: true --> | |
<!-- language: lang-js --> | |
import * as React from 'react'; | |
import ReactDOM from 'react-dom'; | |
import * as Redux from 'redux'; | |
import * as ReactRedux from 'react-redux'; | |
import * as Reselect from 'reselect'; | |
import * as immer from 'immer'; |
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 REMOVE = () => REMOVE; | |
const get = (object, path, defaultValue) => { | |
const recur = (current, path, defaultValue) => { | |
if (current === undefined) { | |
return defaultValue; | |
} | |
if (path.length === 0) { | |
return current; | |
} | |
return recur( |
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 state = { | |
people: { | |
1: { id: 1, name: 'one' }, | |
2: { id: 2, name: 'two' }, | |
3: { id: 3, name: 'three' }, | |
}, | |
likes: { | |
1: [2, 3], | |
2: [1], | |
3: [1], |
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 from 'react'; | |
export const NOT_REQUESTED = { | |
requested: false, | |
loading: false, | |
}; | |
const AVAILABLE = { | |
requested: true, | |
loading: false, | |
}; | |
const isResult = (value) => |
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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
import * as Reselect from 'reselect'; | |
const { | |
useMemo, | |
useState, | |
useContext, | |
useRef, | |
useCallback, |
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 from 'react'; | |
import ReactDOM from 'react-dom'; | |
const useContainer = (props, container) => { | |
return container(props); | |
}; | |
const Counter = ({ counter, up }) => { | |
const r = React.useRef(0); | |
r.current++; | |
return ( |
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
//group promise returning function | |
const createGroup = (cache) => ( | |
fn, | |
getKey = (...x) => JSON.stringify(x) | |
) => (...args) => { | |
const key = getKey(args); | |
let result = cache.get(key); | |
if (result) { | |
return result; | |
} |
NewerOlder