Skip to content

Instantly share code, notes, and snippets.

import { debounce } from "patronum";
import {
Effect,
Event,
guard,
} from "effector";
/**
* отложенный запрос для поиска: ждет 1 сек после последнего события
* и если символов > 2 или 0 передает запрос
* @param searchEvent событие, которое надо дебаунсить
@ulexxander
ulexxander / createConfirmation.ts
Last active January 7, 2022 15:08
Effector factory - Confirmation of some action
import { createEvent, restore, sample } from "effector";
export function createConfirmation<Require, Allow>() {
type Confirmed = { require: Require; allow: Allow };
const require = createEvent<Require>();
const $payload = restore(require, null);
const allow = createEvent<Allow>();
const confirmed = createEvent<Confirmed>();
@afflicted-cat
afflicted-cat / babel.config.js
Last active September 27, 2021 10:01
Nextjs ssr
module.exports = (api) => {
api.cache.using(() => process.env.NODE_ENV);
return {
presets: ["next/babel"],
plugins: [["effector/babel-plugin", { reactSsr: true }]],
};
};
@longdog
longdog / pager.ts
Last active December 18, 2021 17:27
effector antd pager config
export type BaseFilter = {
offset: number;
};
export type BaseList = {
count: number;
};
export function pagerConfig(
pageLimit: number,
$filter: Store<BaseFilter | null>,
@AlexandrHoroshih
AlexandrHoroshih / effector-history-wrap.ts
Created August 20, 2021 19:35
Effector history wrapper
// an option to create bindings to history
// usage is like
//
// export const historyUpdated = createEvent<HistoryUpdate>();
// export const clocks = createHistoryClocks();
//
// clocks have fields like `push, replace, go` and so on
// can be used like clocks.push({ to: "path" })
//
// wrapHistory({
@AlexandrHoroshih
AlexandrHoroshih / next-effector.ts
Last active March 8, 2023 12:12
next/router + effector
import singletonRouter from 'next/router';
import type { NextRouter } from 'next/router';
// import { createDomain } from 'effector';
import { root } from '../../src/core/root';
export const routerDomain = root.createDomain('router');
type NextRouterEventWithError = [any, string];
@AlexandrHoroshih
AlexandrHoroshih / bindings.ts
Last active April 24, 2024 05:13
effector + history
import { matchPath, RouteProps } from "react-router";
// historyUpdated event is subscribed to history via history.listen or any other way
export const createPathMatcher = <Match = unknown>(config: {
path: string | string[] | RouteProps;
clock?: Event<any> | Store<any> | Effect<any, any>;
}) => {
return sample({
source: historyUpdated,
@thisismydesign
thisismydesign / view.controller.ts
Last active January 8, 2024 06:57
NestJS + Next.js /2 View Module
import { Controller, Get, Res, Req } from '@nestjs/common';
import { Request, Response } from 'express';
import { parse } from 'url';
import { ViewService } from './view.service';
@Controller('/')
export class ViewController {
constructor(private viewService: ViewService) {}
@csandman
csandman / README.md
Last active October 11, 2023 10:23
Chakra UI React Select

Chakra React Select

UPDATE: I finally made an NPM package for this component! It is made with TypeScript, and now has a fully customizable styling system. It is also far ahead of this wrapper at this point. Check it out here if you'd like: https://github.com/csandman/chakra-react-select

In order to use this component, you can implement it and use it like you would normally use react-select. It should accept all of the props that the original takes, however customizing the theme or the components could break this implementation. There are also a few extra things you can do with this wrapper that pull from the chakra library.

  • You can pass the size prop with either sm, md, or lg. These will reflect the sizes available on the Chakra <Input /> component (with the exception of xs because it's too small to work).
  • In your options objects, you can add the key isFixed to emulate the exa
@MarZab
MarZab / api-filter-query.ts
Last active March 22, 2025 07:08
NestJS Filters with Swagger deepObject (example: `?filters[name]=thing1&filters[description]=thing2`)
import { applyDecorators } from '@nestjs/common';
import { ApiExtraModels, ApiQuery, getSchemaPath } from '@nestjs/swagger';
/**
* Combines Swagger Decorators to create a description for `filters[name]=something`
* - has support for swagger
* - automatic transformation with nestjs
*/
// eslint-disable-next-line @typescript-eslint/ban-types,@typescript-eslint/explicit-module-boundary-types
export function ApiFilterQuery(fieldName: string, filterDto: Function) {