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
/*@flow*/ | |
export async function getProducts() { | |
return fetch(`/api/products`).then(res => res.json()) | |
} | |
export async function updateVote(id: { id: number }) { | |
return fetch('/api/products/vote/' + String(id)).then(res => res.json()) | |
} |
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
effects: { * query(_, { call, put }: { call: Function, put: Function }) { | |
const { success, data } = yield call(getProducts); | |
if (success) { | |
yield put({ | |
type: 'querySuccess', | |
products: data, | |
}); | |
} | |
}, | |
* vote({ id }: { id: number }, { call, put }: { call: Function, put: 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
reducers: { | |
query(state) { | |
return { ...state, loading: true, }; | |
}, | |
querySuccess(state, { payload }) { | |
return { ...state, loading: false, list: payload }; | |
}, | |
vote(state) { | |
return { ...state, loading: true }; | |
}, |
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
reducers:{ | |
query(state,{ payload }) { | |
return { ...state }; | |
}, | |
querySuccess(state, { payload }) { | |
return { ...state }; | |
}, | |
vote(state, { payload }) { | |
return { ...state }; | |
}, |
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 logo from './logo.svg'; | |
import './App.css'; | |
const App = function() { | |
return ( | |
<div className="App"> | |
<div className="App-header"> | |
<img src={logo} className="App-logo" alt="logo" /> | |
<h2>Welcome to React</h2> | |
</div> |
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
/*@flow*/ | |
import React from 'react'; | |
import { Router, Route } from 'dva/router'; | |
import dva from 'dva'; | |
import App from './App'; | |
import model from './model'; | |
import './index.css'; | |
const app = dva(); | |
app.model(model); |
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
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"net/http" | |
"os" |
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
app.model({ | |
namespace: 'products', | |
state: { | |
list: [], | |
loading: false, | |
}, | |
subscriptions: { | |
setup({ dispatch }) { | |
dispatch({ type: 'query' }); | |
}, |
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
ls -la | |
echo "hello" | |
tree | |
adb devices | |
adb wait-for-device #example of a long running task |
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
#!/bin/sh | |
## Script to patch up diff reated by `repo diff` | |
# from https://groups.google.com/d/msg/repo-discuss/43juvD1qGIQ/7maptZVcEjsJ | |
if [ -z "$1" ] || [ ! -e "$1" ]; then | |
echo "Usages: $0 <repo_diff_file>"; | |
exit 0; | |
fi | |
rm -fr _tmp_splits* |