Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created September 10, 2018 16:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverJAsh/a635f633178a5cde17200ab2f762416e to your computer and use it in GitHub Desktop.
Save OliverJAsh/a635f633178a5cde17200ab2f762416e to your computer and use it in GitHub Desktop.
// actions.ts
import { GalleryItem } from './types';
export enum ActionType {
Search = 'Search',
SearchFailure = 'SearchFailure',
SearchSuccess = 'SearchSuccess',
}
type Search = { type: ActionType.Search; query: string };
export const search = ({ query }: { query: string }): Search => ({
type: ActionType.Search,
query,
});
type SearchFailure = { type: ActionType.SearchFailure };
export const searchFailure = (): SearchFailure => ({
type: ActionType.SearchFailure,
});
type SearchSuccess = { type: ActionType.SearchSuccess; items: GalleryItem[] };
export const searchSuccess = ({
items,
}: {
items: GalleryItem[];
}): SearchSuccess => ({
type: ActionType.SearchSuccess,
items,
});
export type Action = Search | SearchFailure | SearchSuccess;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment