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 withAcknowledgement = (socketFunc) => (...args) => new Promise((resolve, reject) => { | |
let state = 'pending'; // eslint-disable-line | |
const timer = setTimeout(() => { | |
state = 'rejected'; | |
reject(); | |
}, 3000); | |
socketFunc(...args, (response) => { | |
if (state !== 'pending') return; |
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
// Auth провайдер, обертка для прокидывания информации о пользователе | |
const AuthProvider = ({ children }) => { | |
const currentUser = JSON.parse(localStorage.getItem('user')); | |
const [user, setUser] = useState(currentUser ? { username: currentUser.username } : null); | |
const logIn = (userData) => { | |
localStorage.setItem('user', JSON.stringify(userData)); | |
setUser({ username: userData.username }); | |
}; |
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 Map = (props: PropsMap) => { | |
... | |
useEffect(() => { | |
if (!map) { | |
return; | |
} | |
const layerGroup = new LayerGroup(); | |
points.forEach((point) => { |
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 {useEffect, useState, MutableRefObject} from 'react'; | |
import {Map, TileLayer} from 'leaflet'; | |
import {City} from '../types/city'; | |
function useMap( | |
mapRef: MutableRefObject<HTMLElement | null>, | |
city: City | |
): Map | null { | |
const [map, setMap] = useState<Map | null>(null); |
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 const useVideo = (videoRef: RefObject<HTMLVideoElement>, device: MediaDeviceInfo) => { | |
const [started, setStarted] = useState(false); | |
useEffect(() => { | |
if (!videoRef.current || !device) { | |
return noop; | |
} | |
const videoService = new VideoService(); | |
const start = async () => { |
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 { useEffect, useRef } = require("react"); | |
const noop = () => {}; | |
class Editor { | |
constructor(element) { | |
this.element = element; | |
} | |
destroy() { |
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
var simpleObject = { | |
property: 4, | |
method: function () { | |
console.log(this.property); | |
} | |
}; | |
var simpleFunction = function() { | |
this.property = 5; | |
(function() { |
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
// 1 вариант: выхов от результата. Пример задача на суммирование. | |
const fn = (...args) => { | |
const wrapper = () => { | |
return fn; | |
} | |
return wrapper; | |
} | |
console.log(fn()()()()); |
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
{ | |
"id": "42", | |
"author": "Ilya O'Reilly", | |
"comment": "a film that changed my life, a true masterpiece, post-credit scene was just amazing omg.", | |
"date": "2019-05-11T16:12:32.554Z", | |
"emotion": "neutral-face" | |
} |
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
{ | |
"id": "0", | |
"comments": [ | |
$Comment.id$, $Comment.id$ | |
], | |
"film_info": { | |
"title": "A Little Pony Without The Carpet", | |
"alternative_title": "Laziness Who Sold Themselves", | |
"total_rating": 5.3, | |
"poster": "images/posters/blue-blazes.jpg", |
NewerOlder