Skip to content

Instantly share code, notes, and snippets.

View sergeysova's full-sized avatar
👋
Open to network

Sova sergeysova

👋
Open to network
View GitHub Profile

restore

https://effector.now.sh/en/api/effector/restore

Используется тогда, когда необходимо из ивента напрямую выставить значение в стор в обход .on.

Аналог без restore:

const $store = createStore('');
const event = createEvent();
$store.on(event, (_, payload) => payload);
@artalar
artalar / debug-action-call.js
Created March 12, 2019 16:49
Debug where action was called for redux-act
function getStack() {
// Save original Error.prepareStackTrace
const origPrepareStackTrace = Error.prepareStackTrace;
// Override with function that just returns `stack`
Error.prepareStackTrace = (_, stack) => stack;
// Create a new `Error`, which automatically gets `stack`
// Evaluate `err.stack`, which calls our new `Error.prepareStackTrace`
const { stack } = new Error();
import { Reducer } from "redux";
import { Dispatch } from "react-redux";
export type ReducerCur<TState, TPayload = any> = (payloyoad: TPayload) => (state: TState) => TState;
export type ActionCreator<TPayload> = (payload: TPayload) => ({ type: string } & TPayload);
type GetActionCreator<TState, T> = T extends ReducerCur<TState, infer TPayload> ? ActionCreator<TPayload> : void;
export type ActionCreatorsSet<TState, T> = { [TName in keyof T]: GetActionCreator<TState, T[TName]> };
export interface Bundle<TState, TReducersSet> {
@doasync
doasync / README.md
Last active March 6, 2019 17:08
createStoreMap & createMapper for working with lists and collections in effector

Usage of createStoreMap

Create $todos store (with an array) using createStore. Then create a $todoList store using createStoreMap.

There will be a map inside of $todoList store. Define map keys with getKey function and values with createValue function. A value object should contain a store inside which will represent an item of your $todos array. Provide this store with a getStore function.

As a result, $todoList will contain a map of value-objects (by keys). Each object will contain an item-store (with an item of a mapped array)

You can filter, map, concat or do anything you want with items of an array inside $todos.

@lhorie
lhorie / longest-keyword-sequence.md
Last active November 13, 2024 04:15
What's the longest keyword sequence in Javascript?
const createConcurrentRequest = () => {
let lastReq;
return async (request, ...params) => {
let myReq = (lastReq = request(...params));
let response = null;
let error = null;
do {
try {
error = null;
@zerobias
zerobias / mutex.js
Last active December 1, 2018 16:17
Mutex
/* @flow */
class Lock {
release: () => void
sustain = new Promise<void>(resolve => {
this.release = resolve
})
}
export type Releaser<Key> = Promise<() => void>
@zerobias
zerobias / nicknames.md
Last active June 16, 2022 07:44
nicknames
16.06.2022
Дима Zerobias
01.03.2022
⛴➡️🍆
@sergeysova
sergeysova / symbols.js
Created June 13, 2018 14:29
Special symbols usable for variable names
const 〱 = 1;
const ª = 1;
const Á = 1;
const  = 1;
const Å = 1;
const å = 1;
const Æ = 1;
const Ç = 1;
const ç = 1;
const ℇ = 1;

Введение

Конктруктор - является значением. Им можно оперировать в программе как любым дригим значением, Например как строкой или числом

Тип - работает так же как и в других языках

Основы