Skip to content

Instantly share code, notes, and snippets.

View send2moran's full-sized avatar
🎯
Focusing

Moran Helman send2moran

🎯
Focusing
  • Tel Aviv, Israel
View GitHub Profile
@send2moran
send2moran / cloudSettings
Last active May 24, 2021 17:15
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-05-24T17:15:16.776Z","extensionVersion":"v3.4.3"}
This file has been truncated, but you can view the full file.
[
{
"albumId": 1,
"id": 1,
"title": "accusamus beatae ad facilis cum similique qui sunt",
"url": "https://via.placeholder.com/600/92c952",
"thumbnailUrl": "https://via.placeholder.com/150/92c952"
},
{
@send2moran
send2moran / machine.js
Created March 21, 2020 12:40
Generated by XState Viz: https://xstate.js.org/viz
const autoSaveMachine = Machine({
id: 'autosave',
initial: 'idle',
context: {
value: null,
revId: 0,
errorRetryLevels: [10, 30, 300],
errorRetryLevelIdx: 0,
errorCounter: 0
},
@send2moran
send2moran / machine.js
Created March 21, 2020 16:44
Generated by XState Viz: https://xstate.js.org/viz
const autocompleteMachine = Machine({
id: "autocomplete",
type: "parallel",
context: {
hits: [],
highlightedIndex: null
},
states: {
searchBox: {
@send2moran
send2moran / debounceMutationObserver.js
Created April 26, 2020 16:03
debounce MutationObserver
const debounce = (func, delay) => {
let debounceTimer;
return function() {
const context = this;
const args = arguments;
clearTimeout(debounceTimer);
debounceTimer = setTimeout(() => func.apply(context, args), delay);
};
};
let summery = { addded: [], removed: [] };
@send2moran
send2moran / xstate.js
Created January 23, 2022 10:08
useInterpret, useService, useSelector
import { useInterpret, useService, useSelector } from '@xstate/react'
const MyMachineService = React.createContext()
const useMyMachineService = () => {
const service = React.useContext(MyMachineService)
if (!service) {
throw new Error(`useMyMachineService() must be used in a child of <MyMachineProvider>`)
}
return service
}