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
const timeBomb = (millis, misfire =_=> {}) => new Promise( (resolve, reject) => { | |
setTimeout( () => misfire() ? resolve() : reject(), millis ); | |
}); |
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 executeBeforeTimeout(thenable, millis) { | |
return Promise.race([ | |
Promise.resolve(thenable), // 혹시 thenable 하지 않더라도, 명시적으로 Promise 로 변경해준다. | |
timeBomb(millis) // 위에 정의한 지연폭탄 | |
]); | |
} |
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 isThenable(obj) { | |
return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; | |
} |
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 deferredEventer() { | |
// event map. | |
// 이벤트들은 이름 하나당 Set 의 구조를 가진다. | |
const eventMap = new Map(); | |
return new class { | |
/** | |
* 이벤트를 예약한다. |
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 ReactDOM from 'react-dom' | |
function applyClipboard(element, selector) { | |
// implements ... | |
} | |
/** | |
* @Usage | |
* class SomeComponent extends Component {} |
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 from 'react' | |
import { Route } from 'react-router-dom' | |
import { routes } from './routeMap' | |
import Bundle from 'component/bundle/Bundle' | |
import LoadingIndicator from 'component/bundle/LoadingIndicator' | |
const AsyncRoute = ({ component: Component, store, ...rest }) => ( | |
<Route {...rest} render={props => ( | |
<Bundle store={store} load={Component}> | |
{(Component) => { |
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 { injectReducer } from 'store/createRootReducer' | |
const appendReducer = (store, key, reducerModule) => { | |
const reducer = reducerModule.default || reducerModule; | |
injectReducer(store, { key, reducer }); | |
}; | |
// TODO: 계층형 라우팅 추가 필요 | |
export const routes = [ | |
{ |
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
class Diff extends React.Component { | |
constructor(props) { | |
super(props); | |
this.name = "HaHa!" | |
} | |
handleArrow = () => { | |
console.log(this.name); | |
}; |
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
const Test = (_ => { | |
const weakMap = new WeakMap(); | |
return class { | |
constructor() { | |
weakMap.set(this, _=> console.log('test')) | |
} | |
doMethod() { | |
weakMap.get(this)(); | |
} | |
}; |
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
class SomeContainer extends Component { | |
state = { value: '' }; | |
changeText = (e) => this.setState({ | |
value: e.target.value | |
}); | |
componentDidMount() { | |
this.props.findOrder({ orderId: 100012134 }); |
OlderNewer