I hereby claim:
- I am adnaan on github.
- I am adnaan (https://keybase.io/adnaan) on keybase.
- I have a public key ASAgzL2uEUiEMnnqLkRbqECnLs5vet2p2FQF23eFrf45HAo
To claim this, I am signing this object:
| reducers: { | |
| query(state) { | |
| return { ...state, loading: true, }; | |
| }, | |
| querySuccess(state, { payload }) { | |
| return { ...state, loading: false, list: payload }; | |
| }, | |
| vote(state) { | |
| return { ...state, loading: true }; | |
| }, |
| 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 }) { |
| /*@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()) | |
| } |
| import { getProducts, updateVote } from './services'; | |
| export default { | |
| namespace: 'products', | |
| state: { | |
| list: [], | |
| loading: false, | |
| }, | |
| subscriptions: { | |
| init({ dispatch }: { dispatch: Function }) { |
| /*@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); |
| /*@flow*/ | |
| import React from 'react'; | |
| import FaCaretUp from 'react-icons/lib/fa/caret-up'; | |
| function Product(props: { id: number, title: string, vote: number, dispatch: Function }) { | |
| const { id, title, vote } = props; | |
| function handleVote() { | |
| props.dispatch({ | |
| type: 'products/vote', |
| /*@flow*/ | |
| import React from 'react'; | |
| import Product from './Product'; | |
| function ProductList(props: { data: Array < { ID: number, title: string, vote: number } > , dispatch: Function }) { | |
| return ( | |
| <div > | |
| { | |
| props.data.map(product => <Product | |
| key={product.ID} |
| /*@flow*/ | |
| import React from 'react'; | |
| import ProductList from './components/ProductList' | |
| import { connect } from 'react-redux'; | |
| const App = connect(({ products }) => ({ | |
| products | |
| }))(function(props) { | |
| return ( | |
| <div > |
| package main | |
| // Using a global dependency | |
| var userService user.Service | |
| func Init() { | |
| userService = user.NewService() | |
| } | |
| func GetComments() []Comment { | |
| var comments []Comment |
I hereby claim:
To claim this, I am signing this object: