Skip to content

Instantly share code, notes, and snippets.

@baetheus
Created January 18, 2019 19:46
Show Gist options
  • Select an option

  • Save baetheus/a812da61eb686eddbe3ba3a9e8a9c2c6 to your computer and use it in GitHub Desktop.

Select an option

Save baetheus/a812da61eb686eddbe3ba3a9e8a9c2c6 to your computer and use it in GitHub Desktop.
Example action + reducer + lens + epic
/**
* Get Campaigns
*/
export const getCampaigns = contactStrategyActionFactory.async<number, Campaign[], Error>('GET_CAMPAIGNS');
export const campaignsLens = Lens.fromProp<ContactStrategyStore, 'campaigns'>('campaigns');
const getCampaignsReducer = reducerFactory(getCampaigns, campaignsLens);
const getCampaignsEpic: Epic = a$ =>
a$.pipe(
filterSwitchAsync(getCampaigns, companyId => from(GetCampaigns({ companyId }).then(({ campaigns }) => campaigns)))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment