Skip to content

Instantly share code, notes, and snippets.

View popuguytheparrot's full-sized avatar
🦜
Hyping Solid.js

popuguy popuguytheparrot

🦜
Hyping Solid.js
View GitHub Profile
import { useCallback, useContext, useEffect, useRef, useState } from 'react';
import { UserContext } from 'src/contexts/User';
import { v4 } from '@lukeed/uuid';
import { NoteEntityType, NoteRes } from 'src/typings/notes';
import { requestAddNote, requestSaveNote } from 'src/apiServices/notes';
import { EntityState, useEntityState } from 'src/hooks/useEntityState';
import debounce from 'lodash.debounce';
interface EditField {
field: keyof NoteRes;
import { createEvent, createStore, combine, sample, forward } from 'effector';
import { accessTypes } from 'constants/access-type';
/**
*
* @type {Event<{title, content, contentText, cb}>}
*/
export const openPopover = createEvent('open Popover');
export const closePopover = createEvent('close Popover');
import { createEvent, createStore, forward, guard, sample } from 'effector';
import nanoid from 'nanoid';
export const show = createEvent('show Notify');
export const hide = createEvent('hide Notify');
/**
* @type {Event<{variant: string, message: string}>}
* @property {string} variant info | success | warning | error
*/
@popuguytheparrot
popuguytheparrot / model.js
Last active October 28, 2019 10:07
terminal page
import {
createEffect,
createEvent,
createStore,
sample,
merge,
guard,
forward
} from 'effector';
@popuguytheparrot
popuguytheparrot / api.js
Created October 1, 2019 09:56
ky with proxy
import { ky } from './ky.config';
const employeesUrl = 'employees';
export async function fetchEmployees() {
return ky.get(employeesUrl).json();
}
@popuguytheparrot
popuguytheparrot / file.js
Last active March 4, 2021 13:24
ws store effector
import { createEffect, createEvent, createStore, merge } from 'effector';
import nanoid from 'nanoid';
import { request, parseObject } from 'jsonrpc-lite';
const wsURL = `ws://localhost:${process.env.WS_PORT}`;
let socket;
const awaitingMap = new Map();
function cleanSocket() {
@popuguytheparrot
popuguytheparrot / App.js
Last active May 16, 2021 01:17
L10N with effector.js
import {useLocalize, addTranslate} from './useLocalize'
addTranslate({
lang: 'ru',
translates: {
greeting: 'Добро пожаловать, снова'
}
});
export function App() {
@popuguytheparrot
popuguytheparrot / useWS.js
Last active March 6, 2024 16:25
websocket hook with effector
import { useEffect, useRef, useCallback } from 'react';
import { createEvent, createStore } from 'effector';
import { useStore } from 'effector-react';
const open = createEvent('open');
const closed = createEvent('closed');
const error = createEvent('error');
const wsStatus = createStore('closed')
// На входе массив
var arr = [
{name: 'width', value: 10},
{name: 'height', value: 20}
];
// На выходе объект {width: 10, height: 20}
const obj = arr.reduce((acc, {name, value}) => acc[name] = value,{})
Углифай без транспиляции для современных браузеров
<script type="module" src="bandle.js">
С транспиляцией и прочим
<script nomodule src="fallback.js"></script>