Facebook 在整合自家功能上存在一些公開原則,並且推出產品前會需要將完成的服務交給 Facebook 審核團隊檢查,這份文件將美術設計與產品設計者所需了解的資訊整理出來,協助參考流程與畫面設計。
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
// Reference from @github/fetch issue 175 | |
// https://github.com/github/fetch/issues/175#issuecomment-125779262 | |
function timeoutPromise(ms, promise) { | |
return new Promise((resolve, reject) => { | |
const timeoutId = setTimeout(() => { | |
reject(new Error("promise timeout")) | |
}, ms); | |
promise.then( | |
(res) => { | |
clearTimeout(timeoutId); |
- GitHub - https://github.com/Calvin-Huang
- LinkedIn - https://www.linkedin.com/in/calvin-huang/
- StackOverflow - https://stackoverflow.com/users/5549119/calvin-huang
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 repos = []; | |
var bookmarks = []; | |
var page = 1; | |
const repoList = $ | |
.templates( | |
'repo-list', | |
{ markup: '#repo-list', templates: { repo: $.templates('#repo') } }, | |
); |
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
store.subscribe(() => { | |
const action = store.getState().lastAction; | |
switch (action.type) { | |
case START_REQUEST: { | |
fetch('/api/v1/foo') | |
.then(response => response.json()) | |
.then((data) => { | |
store.dispatch(receive(data)); | |
}) |
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 middleware = (store) => { | |
return next => action => { | |
// Dispathcing action. | |
const returnValue = next(action); | |
// Action dispatched. | |
const state = store.getState(); | |
switch (action.type) { | |
case START_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
import { createStore, applyMiddleware } from 'redux'; | |
import thunk from 'redux-thunk'; | |
import rootReducer from './reducers/index'; | |
// Note: this API requires redux@>=3.1.0 | |
const store = createStore( | |
rootReducer, | |
applyMiddleware(thunk) | |
); |
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 pingEpic = action$ => | |
action$.filter(action => action.type === 'PING') | |
.mapTo({ type: 'PONG' }); | |
// later... | |
dispatch({ type: 'PING' }); |
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 { call, put } from 'redux-saga/effects' | |
export function* fetchData(action) { | |
try { | |
const data = yield call(Api.fetchUser, action.payload.url) | |
yield put({type: "FETCH_SUCCEEDED", data}) | |
} catch (error) { | |
yield put({type: "FETCH_FAILED", error}) | |
} | |
} |