This file contains 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 $$timeoutId = 0; | |
const deferreds = {}; | |
function $timeout(fn, delay) { | |
const timeoutId = $$timeoutId++; | |
let cachedReject; | |
const reject = (e) => cachedReject(e); | |
const promise = new Promise((resolve, reject) => { | |
cachedReject = reject; |
This file contains 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 default function memoizeOnce(callback, isChanged) { | |
let firstTime = true; | |
let lastFirstArg, lastRes; | |
return function memoizedOnce() { | |
if (firstTime) { | |
lastRes = callback.apply(null, arguments); | |
lastFirstArg = arguments[0]; | |
firstTime = false; | |
} else if ( |
This file contains 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 React, { Component } from "react"; | |
import PropTypes from "prop-types"; | |
import { | |
View, | |
Text, | |
TextInput, | |
TouchableOpacity, | |
ScrollView, | |
} from "react-native"; |
This file contains 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
function traverseWrapForDev(fn) { | |
if (__DEV__) { | |
return (...args) => { | |
try { | |
return fn.apply(null, args) | |
} catch (err) { | |
throw new Error(err) | |
} | |
} | |
} |
This file contains 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 function createLeafReducer(initialState, HANDLERS) { | |
return function leafReducer(state, action) { | |
if (typeof state === 'undefined') return initialState; | |
const HANDLER = HANDLERS[action.type]; | |
if (typeof HANDLER === 'undefined') return state; | |
if (typeof HANDLER !== 'function') return HANDLER; | |
var newState; |
This file contains 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 { Styler } from '../style/react-native-styler'; | |
/* | |
если заменить StyleSheet.create({}) на Styler.create({}) | |
то все будет работать аналогично, включая перфоманс оптимизации | |
к итоговому обьекту добавляется метод .$(), работающий аналогично вебовскому classNames | |
плюс, в Styler.create можно загнать функцию, аргументом в которые отправляется глобальная тема и утилиты | |
*/ |
This file contains 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
// мне не нравится как this передается | |
function onSimpleHashChange(handlers) { | |
const keys = _.keys(handlers); | |
return function (left, right) { | |
if (_.isEqual(left, right)) {return} | |
const _this = this; | |
keys.forEach((key) => { |
This file contains 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
// Дэн проводит мысленный переход с одной функции, к разделению на ветки | |
// http://redux.js.org/docs/basics/Reducers.html | |
// в ишью на вопрос "хорошо ли использовать комбайн-редюсеры внутри редюсеров" | |
// https://github.com/reactjs/redux/issues/738, Дэн отвечает утвердительно | |
// При этом предложенное им решение комбайнРедюсера продолжает оставаться флет, заставляя раскладывать | |
// схему приложения в один уровень (не давая использовать удобство иерархии), | |
// а внутренюю оставляя на усмотрение разработчика |
This file contains 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
.page-main * { | |
background: rgba(0, 0, 0, .025); | |
padding: 5px; | |
margin: 5px; | |
} | |
.page-main *:after { | |
content: attr(class); | |
font-size: 12px; | |
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; | |
font-style: italic; |
This file contains 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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, {Component} from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, |
NewerOlder