Skip to content

Instantly share code, notes, and snippets.

@7iomka
7iomka / use-dispsable.ts
Created March 4, 2023 13:52
Disposable example of usage
const updateFiltersTriggered = createEvent();
// Handle edit (update) or add a new row of single filter configuration
const updateFiltersConfigurationRowFx = attach({
source: $filterConfigs,
effect: updateFx,
mapParams: ({ key, data }: { key: string; data: FilterConfiguration }, configs) =>
});
@7iomka
7iomka / disposable.ts
Last active August 9, 2024 19:45
Disposable
/* eslint-disable consistent-return */
/* eslint-disable effector/mandatory-scope-binding */
/* eslint-disable effector/no-watch */
import type { Node } from 'effector';
import {
clearNode,
attach,
// combine,
createEffect,
createNode,
@7iomka
7iomka / adapters~address-suggest.tsx
Created February 28, 2023 21:12
Adapters example (Mantine ui)
import { AddressSuggestInput as NativeAddressSuggestInput } from '@/shared/ui';
import { withField } from '../field';
export const AddressSuggestInput = withField(NativeAddressSuggestInput, { isDadataField: true });
@7iomka
7iomka / factory.ts
Created February 28, 2023 21:04
Factory example
import { createLib, ValidationVisibilityCondition } from '@filledout/core';
import { createLib as createReactLib } from '@filledout/react';
import type { ApplyYupParams } from '@filledout/yup';
import { applyYup } from '@filledout/yup';
import type { FormModel, CreateFormParams } from '@filledout/core';
import type { AxiosError } from 'axios';
import { isAxiosError } from 'axios';
import type { EffectParams, Effect } from 'effector';
import { createEffect, is, sample } from 'effector';
import { getErrorsMap, isCustomAxiosError } from '../api';
import { Button, Group } from '@mantine/core';
import { Form, useForm } from '@/shared/form';
import { createView } from '@/shared/lib/view';
import { $$simple } from './simple-form.model';
const SimpleForm = createView()
.units({
stepIndex: $$simple.$stepIndex,
steps: $$simple.$steps,
handleNextStep: $$simple.nextStepLoaded,
@7iomka
7iomka / [[...url]].tsx
Created February 21, 2023 22:29
Effector & next.js issue with units lose their state or mixed up - when catchAll + layout component as property used
// CatcAll pages (static)
import type { GetStaticPaths } from 'next';
import type { ReactNode } from 'react';
import type { CustomizeGSPParams } from 'nextjs-effector';
import { createGSP } from '@/app/page-factories/base-layout-pages'; // <<-- uses event from model from base-layout widget
import { $$all, All, AllSeo } from '@/pages/all'; // <--
import { BaseLayout } from '@/widgets/layouts/base-layout'; // <--
import type { SitemapItemEntity } from '@/shared/api';
import { api } from '@/shared/api';
@7iomka
7iomka / get-initial-props.ts
Created February 18, 2023 18:08
Effector & Next.js
const createServerScope = () => fork()
async function getInitialProps(context) {
/*
* Determine the Effector events to run
*
* On server-side, use both shared and page events
*
* On client-side, use only page event,
* as we don't want to run shared events again
@7iomka
7iomka / form.component.tsx
Last active February 13, 2023 18:07
Help wanted with wizzard forms
import { Button, Group, Radio } from '@mantine/core';
import { Form, FormField } from '@/shared/form-next';
import { useForm } from '@/shared/form-next/factory';
import { createView } from '@/shared/lib/view';
import { $$simple } from './simple-form.model';
const SimpleForm = createView()
.units({
stepIndex: $$simple.$stepIndex,
steps: $$simple.$steps,
а вот теперь в отношении девушек я думаю в этом отношении это еще более понятнее да я говорю это всем без исключения девушками и женщинам сестры вот бог удивительным образом вас создал на самом деле мы созданы прекрасно вы созданы возвышенно вы созданы изящно вы созданы на порядок лучше и намного творчески красивее нежели мы мужчины у нас начиная от простых вещей и все намного примитивнее проще но вы созданы на самом деле очень возвышенно и красиво но вам нужно этим пользоваться правильно и я приведу вам простой пример думаю он будет очень понятен и очень ясный вот представьте себе что вы рано утром пропустили завтрак представьте себе по каким то причинам вы не смогли попасть на обед и вы получается почти целый день уже голодный и вы наступает время ужина и вот вы переступаете порог своего родного дома и представьте себе что дома как раз расположен кто-то свое сердце приготовить на ужин такую запеченную румяную корочку и и чесночком натирали ее в духовочке запекли и вот вы переступаете порог своего родного до
import type { EventPayload, UnitValue } from 'effector';
import { attach, createEvent, createStore, sample, split } from 'effector';
import { interval } from 'patronum/interval';
import produce from 'immer';
import { $$cart } from '@/entities/cart';
import type { ChangeProductCartDto, ProductNeedUrgencyEnum } from '@/shared/api';
type ItemStatus = {
updating?: boolean;
metaBeforeRemoval?: {