This file contains 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
declare function searchForMovies(query?: string): Promise<Movie[]> | |
declare function MovieList(props: { movies: Movie[] }): JSX.Element | |
declare function LoadingIndicator(props: { loadingSince: Date }): JSX.Element | |
declare function ErrorMessageUI(props: { error: Error }): JSX.Element | |
type Movie = { title: string, id: string } | |
type ViewState = ( | |
{ status: 'loading', loadingSince: Date } | | |
{ status: 'done', searchResults: Movie[] } | |
This file contains 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
declare function searchForMovies(query?: string): Promise<Movie[]> | |
declare function MovieList({ movies }: { movies: Movie[] }): JSX.Element | |
declare function LoadingIndicator(): JSX.Element | |
declare function ErrorMessageUI({ message }: { message: string }): JSX.Element | |
type Movie = { title: string, id: string } | |
type ViewState = { | |
loading: boolean, | |
error?: Error, | |
searchResults?: Movie[], |
This file contains 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
declare function searchForMovies(query?: string): Promise<Movie[]> | |
declare function MovieList(props: { movies: Movie[] }): JSX.Element | |
declare function LoadingIndicator(): JSX.Element | |
declare function ErrorMessageUI(props: { message: string }): JSX.Element | |
type Movie = { title: string, id: string } | |
export function MovieSearch() { | |
const [searchTerm, setSearchTerm] = useState<string>('') | |
const [searchResults, setSearchResults] = useState<Movie[]>() |
This file contains 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
type ThunkAction<T> = (dispatch: Dispatch<T>) => T | |
type AsyncDispatch<T> = Dispatch<T | ThunkAction<T>> | |
function wrapAsync<T>(dispatch: Dispatch<T>): AsyncDispatch<T> { | |
return function(action: T | ThunkAction) { | |
if (action instanceof Function) { | |
return action(dispatch) | |
} | |
return dispatch(action) | |
} |
This file contains 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
type AsyncDispatch<T> = Dispatch<T | Promise<T>> | |
function wrapAsync<T>(dispatch: Dispatch<T>): AsyncDispatch<T> { | |
return (action: T | Promise<T>) => { | |
if (action instanceof Promise) { | |
return action.then(dispatch) | |
} | |
return dispatch(action) | |
} | |
} |
This file contains 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
/** | |
* SomeUtilFile.tsx | |
* | |
* Generic wrapper for async dispatch | |
*/ | |
export function useAsyncReducer<T>(initial: T, reducer: Reducer<T, Action>): [T, AsyncDispatch<T>] { | |
let [state, dispatch] = useReducer<T>(reducer, initial) | |
let wrappedDispatch = useMemo(() => wrappedDispatch(dispatch), [dispatch]) | |
let stateWithWrappedDispatch = useMemo(() => [state, wrappedDispatch], [state, wrappedDispatch]) |
This file contains 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
/** | |
* SomeUtilFile.tsx | |
* | |
* Generic wrapper for creating store reducer and connecting actions | |
*/ | |
export function useAsyncReducer<T>(initial: T, reducer: Reducer<T, ReducerAction<T>>, actions: AsyncActions<T>): [T, ConnectedActions<T>] { | |
let [state, dispatch] = useReducer<T>(reducer, initial) | |
let connectedActions = useMemo(() => connectActionsToDispatch(actions, dispatch), [dispatch, actions]) | |
let stateAndConnectedActions = useMemo(() => [state, connectedActions], [state, connectedActions]) |
This file contains 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
define(function(require, exports, module) { | |
var Engine = require('famous/core/Engine'); | |
var Surface = require('famous/core/Surface'); | |
var ScrollView = require('famous/views/ScrollView'); | |
var SequentialLayout = require('famous/views/SequentialLayout'); | |
var mainContext = Engine.createContext(); | |
mainContext.setPerspective(1000); | |
// Create top surface |
This file contains 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
define(function(require, exports, module) { | |
var Engine = require('famous/core/Engine'); | |
var Modifier = require('famous/core/Modifier'); | |
var Surface = require('famous/core/Surface'); | |
var RenderController = require('famous/views/RenderController'); | |
var context = Engine.createContext(); | |
var rc = new RenderController(); |
This file contains 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
define(function(require, exports, module) { | |
var Transitionable = require('famous/transitions/Transitionable'); | |
function CustomTransitionable() { | |
Transitionable.apply(this, arguments); | |
} | |
CustomTransitionable.prototype = Object.create(Transitionable.prototype); | |
CustomTransitionable.prototype.constructor = CustomTransitionable; |
NewerOlder