Skip to content

Instantly share code, notes, and snippets.

type BaseEventsMap = {
[key: string]: any[]; // ключ - название события, значение - возможные аргументы
};
type Callback<P extends any[]> = (...payload: P) => void;
class EventEmitter<EventsMap extends BaseEventsMap> {
events: Map<keyof EventsMap, Set<Callback<EventsMap[keyof EventsMap]>>> = new Map();
on<E extends keyof EventsMap>(event: E, callback: Callback<EventsMap[E]>): Function {
enum ServicesNames {
WorldService = 'WorldService',
Window = 'WindowService',
DateService = 'DateService',
}
type IServicesList = {
[ServicesNames.WorldService]?: WorldService;
[ServicesNames.Window]?: WindowService;
[ServicesNames.DateService]?: DateService;
import { IContent } from '../../common/mapi/entities/content/Content.h';
import { IPurchaseOptions } from '../../common/mapi/entities/billing/purchaseOptions/PurchaseOptions.h';
import { IVideoWatchTime } from '../../common/mapi/entities/content/WatchTime.h';
import {
getObjectMinPurchaseOption,
getObjectPurchases,
getPurchaseFinishTime,
getPurchaseOptionCurrencySymbol,
getPurchaseOptionDiscountDescription,
getPurchaseOptionPrice,
import * as React from 'react';
const HeaderBar: any = () => null;
const BreadCrumbs: any = () => null;
const PageSection: any = () => null;
const MainContent: any = () => null;
const TopInfo: any = () => null;
const AgeBadge: any = () => null;
const Title: any = () => null;
const Parameters: any = () => null;
const state = [{
id: 1,
active: false,
loaded: false,
}, {
id: 2,
active: false,
loaded: false,
}, {
id: 3,
// entities/video/index.ts
type IVideo = {
src: string;
}
const getVideoSrc = (video: IVideo): number => {
return video.src;
}
const setVideoSrc = (video: IVideo, src: string): number => {
Цикл API + Store + UI:
1) Модели в API
API/EntityFoo {
id,
bars: [ API/EntityBar ],
bazs: [ API/EntityBaz ],
…otherProps
}
const logger = require('../services/logger');
const needModifyResponse = (req, res) => {
return res.get('content-type') === 'application/json' && !req.path.includes('ajax');
};
/**
* Промежуточный обработчик запросов для модификации ответа от сервера
*/
const resJsonToHtmlMiddleware = (req, res, next) => {
<body
data-rocket-page
data-rocket-info="{
'properties': {
'ui_type': 'content_page',
'ui_id': 'card',
'ui_title': 'Мстители: Война бесконечности',
'content_id': 123456
},
'details': [{
enum States {
Empty = 'empty',
Liked = 'liked',
Disliked = 'disliked'
}
enum Actions {
Like = 'LIKE_ACTION',
Dislike = 'DISLIKE_ACTION'
}