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/713183a57a6e70f06f41bfb0943d1615 to your computer and use it in GitHub Desktop.
Save OliverJAsh/713183a57a6e70f06f41bfb0943d1615 to your computer and use it in GitHub Desktop.
// actions.ts
import { ofType, unionize, UnionOf } from 'unionize';
import { GalleryItem } from './types';
export type SearchAction = { query: string };
export const Action = unionize(
{
Search: ofType<SearchAction>(),
SearchFailure: ofType<{}>(),
SearchSuccess: ofType<{ items: GalleryItem[] }>(),
},
// Tag must be `type` to conform to expected Redux action type.
{ tag: 'type' },
);
export type Action = UnionOf<typeof Action>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment