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
type ValueOf<T> = T[keyof T]; | |
type ArrayPath<T> = | |
T extends Array<unknown> | |
? ArrayPath<Omit<T, keyof []>> | |
: T extends object | |
? ValueOf<{ | |
[K in keyof T]: [K] | [K, ...ArrayPath<T[K]>]; | |
}> | |
: never; |
https://effector.now.sh/en/api/effector/restore
Используется тогда, когда необходимо из ивента напрямую выставить значение в стор в обход .on
.
Аналог без restore
:
const $store = createStore('');
const event = createEvent();
$store.on(event, (_, payload) => payload);
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 TIMEOUT = 500 | |
patterns = { | |
's-r': [83, 82] | |
} | |
handler = e => { | |
// console.log(e.which) | |
clearTimeout(handler.timer) | |
handler.keys[e.which] = true |
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
// A simple counter example | |
// The setup will be more complicated in modern apps built using React | |
const incrementNode = document.getElementById('increment'); | |
const decrementNode = document.getElementById('decrement'); | |
const inputNode = document.getElementById('counter'); | |
const counter = { | |
initialize() { | |
incrementNode.addEventListener('click', (event) => { |
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
100+ different js counter apps... |
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
|
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 I = x => x | |
const K = x => y => x | |
const A = f => x => f (x) | |
const T = x => f => f (x) | |
const W = f => x => f (x) (x) | |
const C = f => y => x => f (x) (y) | |
const B = f => g => x => f (g (x)) | |
const S = f => g => x => f (x) (g (x)) | |
const S_ = f => g => x => f (g (x)) (x) | |
const S2 = f => g => h => x => f (g (x)) (h (x)) |
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
/*eslint-env es6 */ | |
// Inspired by the paper "A tutorial on the universality and | |
// expressiveness of fold" by Graham Hutton (available at | |
// http://www.cs.nott.ac.uk/~gmh/fold.pdf), implementing some generic | |
// list handling functions in JavaScript in terms of `fold`. | |
// Personally I had an enlightnening moment when I realised the | |
// beautiful interplay of cons lists and foldr during the FP101x | |
// Haskell course. JavaScript's syntax doesn't make this very apparent |
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
var touchstartX = 0; | |
var touchstartY = 0; | |
var touchendX = 0; | |
var touchendY = 0; | |
var gesuredZone = document.getElementById('gesuredZone'); | |
gesuredZone.addEventListener('touchstart', function(event) { | |
touchstartX = event.screenX; | |
touchstartY = event.screenY; |
NewerOlder