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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Ansi 0 Color</key> | |
<dict> | |
<key>Alpha Component</key> | |
<real>1</real> | |
<key>Blue Component</key> | |
<real>0.0</real> |
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
MULTI | |
ZADD rsmq:{queueName} {epoch} {id} | |
HSET rsmq:{queueName}:Q {id} {message} | |
HINCRBY rsmq:{queueName}:Q totalsent 1 | |
EXEC |
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 { useCallback, Reducer, ReducerState, ReducerAction } from "react"; | |
import { useReducer } from "reinspect"; | |
export type StateGetter<A extends Reducer<any, any>> = () => ReducerState<A>; | |
export type DispatchThunk<A extends Reducer<any, any>> = ( | |
dispatch: (value: ReducerAction<A>) => void, | |
state: StateGetter<A> | |
) => void; | |
export type DispatcherThunk<A extends Reducer<any, any>> = ( | |
action: ReducerAction<A> | DispatchThunk<A> |
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 * as React from "react"; | |
import { usePokemonReducer, fetchPokemons } from "./pokemon.ducks"; | |
export default function App() { | |
const [state, dispatch] = usePokemonReducer(); | |
function handleOnClick() { | |
dispatch(fetchPokemons()); | |
} |
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
// FINALY EXPOSE THE REDUCER | |
export const usePokemonReducer = () => | |
useThunkReducer(reducer, initialState, "pokemons"); |
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
// ACTION CREATORS | |
export const fetchPokemons = () => { | |
return async (dispatch: Dispatch<PokemonAction>) => { | |
dispatch({ type: "FETCH_POKEMON_PENDING" }); | |
try { | |
const result: { results: Pokemon[] } = await (await fetch( | |
"https://pokeapi.co/api/v2/pokemon" | |
)).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
// REDUCER | |
function reducer(state: PokemonState, action: PokemonAction): PokemonState { | |
switch (action.type) { | |
case "FETCH_POKEMON_PENDING": | |
return { ...state, isLoading: true }; | |
case "FETCH_POKEMON_COMPLETED": | |
return { ...state, isLoading: false, pokemons: action.pokemons }; | |
case "FETCH_POKEMON_FAILED": | |
return { ...state, isLoading: false, pokemons: [] }; | |
} |
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
// INITIAL STATE & TYPE DEFINITION | |
type Pokemon = { | |
name: string; | |
url: string; | |
}; | |
type PokemonState = { | |
pokemons: Pokemon[]; | |
isLoading: boolean; | |
}; |
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
// ACTIONS | |
type FetchPokemonPending = { | |
type: "FETCH_POKEMON_PENDING"; | |
}; | |
type FetchPokemonCompleted = { | |
type: "FETCH_POKEMON_COMPLETED"; | |
pokemons: Pokemon[]; | |
}; |
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
// Actions Type Definition | |
type AsyncActionPending = { | |
type: "ASYNC_ACTION_PENDING"; | |
}; | |
type AsyncActionFulfilled = { | |
type: "ASYNC_ACTION_FULFILLED"; | |
}; | |
type AsyncAction = AsyncActionPending | AsyncActionFulfilled; |
NewerOlder