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
using System; | |
using System.Net; | |
namespace ConsoleApplication1 | |
{ | |
class Program | |
{ | |
public class WebClientEx : WebClient | |
{ | |
public WebClientEx(CookieContainer container) |
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 datagen | |
import com.github.javafaker._ | |
import java.io.File | |
import java.io.PrintWriter | |
import java.time.temporal.ChronoUnit.DAYS | |
import java.time._ | |
import scala.util.Random | |
object DataGen { |
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 scala.collection.mutable.Queue | |
object Page extends App { | |
val apiData = Queue(1000,1000,1000,1000,1000,10) | |
Stream.from(1).takeWhile(getPage(_).nonEmpty).foreach(_ => processData()) | |
def getPage(x: Int): Queue[Int] = { return apiData } | |
def processData(){ println(apiData.dequeue()) } |
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 { useSelector, useDispatch } from 'react-redux'; | |
import { RootState } from '~/reducers'; | |
import { selectUser, selectAllUsers } from 'actions/app'; | |
import { setUserAction, setAllUsersAction } from '../actions/app'; | |
export const useUserState = () => { | |
return { | |
user: useSelector((state: RootState) => selectUser(state)), | |
allUsers: useSelector((state: RootState) => selectAllUsers(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 { AnyAction, applyMiddleware, compose, createStore } from 'redux'; | |
import combinedReducers, { RootState } from '../reducers'; | |
import thunk, { ThunkMiddleware } from 'redux-thunk'; | |
const devToolsCompose = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__; | |
const composeEnhancers = (devToolsCompose !== null && devToolsCompose !== undefined) | |
? devToolsCompose | |
: compose; | |
export type ThunkWithRootState = ThunkMiddleware<RootState, AnyAction>; |
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 { setData } from '../actions'; | |
export const getDataWithThunk = () => { | |
return (dispatch) => { | |
fetch(url) | |
.then(resp => resp.json()) | |
.then(data => dispatch(setData(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
// typically this lives where the provider wraps the root component | |
import { store } from './location-of-instantiated-store'; | |
import { setData } from '../actions'; | |
export const getDataWithSingletonStore = () => { | |
fetch(url) | |
.then(resp => resp.json()) | |
.then(data => store.dispatch(setData(data))); | |
}; |
OlderNewer