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 utils = utils || {}; | |
// [..] | |
utils.page = (function() { | |
var previousState = History.getState(); | |
return function() { | |
var state = History.getState(); |
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 React from 'react'; | |
import { navigateAction, handleRoute } from 'fluxible-router'; | |
import connectToStores from 'fluxible/addons/connectToStores'; | |
import _debounce from 'lodash/function/debounce'; | |
import SearchStore from '../../../stores/SearchStore'; | |
import SearchPageList from './SearchPageList'; | |
class SearchPage extends React.Component { |
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
function getFrontMatter(file) { | |
return new Promise((resolve, reject) => { | |
readFile(join(__dirname, '../pages', file), (error, content) => { | |
if (error) return reject(error); | |
let doc = fm(content.toString()) | |
resolve(doc); | |
}); | |
}) | |
} |
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 obj = { | |
a: 1, | |
b: 2, | |
c: 3, | |
d: 4, | |
}; | |
const { | |
a, | |
b, |
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 React, { PropTypes } from 'react'; | |
function NL2BR({content}) { | |
const strs = content.split('\n'); | |
const {length} = strs; | |
if (length === 1) { | |
return <span>{content}</span>; | |
} |
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
/ ) | |
/ )__/ )_____/ / | |
( @ . @ ) ) | |
( ) | |
//¨//¨¨//¨// |
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 { ApolloClient, createNetworkInterface } from 'react-apollo'; | |
let apolloClient = null; | |
function createClient(headers, userToken) { | |
const networkInterface = createNetworkInterface({ | |
uri: 'https://api.graph.cool/simple/v1/Groopy', | |
opts: { | |
credentials: 'same-origin', | |
// Pass headers here if your graphql server requires them |
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
/** | |
* retry async operaration up to N times | |
* | |
* usage: | |
* ```ts | |
* async fn() { | |
* const response = await retry(() => fetch('/endpoint/that/might/fail'), 3) | |
* } | |
* fn() // will retry fetch up to 3 times | |
* ``` |
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
/* eslint-disable no-underscore-dangle */ | |
module.exports = ({ | |
processEventEmitter, | |
logger, | |
skipRecurringOperationRefetch, | |
}) => | |
class RecurringOperation { | |
constructor({ operation, expiry = null }) { | |
if (typeof operation !== '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
function deferred<T>() { | |
let resolve: (value: PromiseLike<T> | T) => void; | |
let reject: (reason: Error) => void; | |
let promise = new Promise<T>((_resolve, _reject) => { | |
resolve = _resolve; | |
reject = _reject; | |
}); | |
return { promise, resolve, reject }; | |
} |