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
поясню:
1) Сначала выделяем все что используется более 3х раз в common асинхронный.
2) Из остатков экстрактим node_modules из всех дочерних чанков
3) Все пихаем в entry chunk
new webpack.optimize.CommonsChunkPlugin({
name: 'app',
async: 'common',
Углифай без транспиляции для современных браузеров
<script type="module" src="bandle.js">
С транспиляцией и прочим
<script nomodule src="fallback.js"></script>
// На входе массив
var arr = [
{name: 'width', value: 10},
{name: 'height', value: 20}
];
// На выходе объект {width: 10, height: 20}
const obj = arr.reduce((acc, {name, value}) => acc[name] = value,{})
@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')
@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 / 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 / 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 / model.js
Last active October 28, 2019 10:07
terminal page
import {
createEffect,
createEvent,
createStore,
sample,
merge,
guard,
forward
} from 'effector';
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
*/
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');