This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Store, Unsubscribe } from 'redux'; | |
| const defaultEqual = <P>(prev: P, next: P) => prev === next; | |
| const defaultImmediately = true; | |
| interface IWatcherParams<S, V, P> { | |
| store: Store<S>; | |
| selector: (state: S, params?: P) => V; | |
| onChange: (prev: V, next: V) => void; | |
| props?: P; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const path = require('path'); | |
| const webpack = require('webpack'); | |
| const vendor = [ | |
| { library: 'jquery', globals: ['jQuery', '$'] }, | |
| { library: 'react', globals: ['React'] }, | |
| { library: 'react-dom', globals: ['ReactDOM'] } | |
| ]; | |
| const createExposeLoader = (config) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Обработка opaque response https://stackoverflow.com/questions/39109789/what-limitations-apply-to-opaque-responses | |
| // По умолчанию, ответы без Content-Length резервируют очень много пространства в хранилище браузера | |
| const OpaqueResponsePlugin = { | |
| // Меняем mode и credentials у запроса | |
| requestWillFetch: async ({request}) => { | |
| if (request.mode === 'cors' && request.credentials === 'same-origin') { | |
| return request; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Класс для сбора и отложенного выполнения команд. | |
| * | |
| * Кейс для использования - класс с динамическим импортом модуля, | |
| * методы которого должны сработать после успешной загрузки этого модуля. | |
| */ | |
| export class CommandExecutor { | |
| private ready = false; | |
| private commands: Map<string, any[]> = new Map(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * State | |
| * | |
| * Для начала определим интерфейс этого кусочка хранилища, | |
| * и создадим объект с начальным состоянием. | |
| */ | |
| export interface FieldState { | |
| value: string; | |
| focus: boolean; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public function isBrowser() | |
| { | |
| $arguments = func_get_args(); | |
| return $this->browserDetector->isBrowser(...$arguments); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| enum States { | |
| Empty = 'empty', | |
| Liked = 'liked', | |
| Disliked = 'disliked' | |
| } | |
| enum Actions { | |
| Like = 'LIKE_ACTION', | |
| Dislike = 'DISLIKE_ACTION' | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <body | |
| data-rocket-page | |
| data-rocket-info="{ | |
| 'properties': { | |
| 'ui_type': 'content_page', | |
| 'ui_id': 'card', | |
| 'ui_title': 'Мстители: Война бесконечности', | |
| 'content_id': 123456 | |
| }, | |
| 'details': [{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Цикл API + Store + UI: | |
| 1) Модели в API | |
| API/EntityFoo { | |
| id, | |
| bars: [ API/EntityBar ], | |
| bazs: [ API/EntityBaz ], | |
| …otherProps | |
| } |