Skip to content

Instantly share code, notes, and snippets.

@OliverJAsh
Created November 22, 2018 08:32
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/3a27766b54c038c808cb2a23e210c2a3 to your computer and use it in GitHub Desktop.
Save OliverJAsh/3a27766b54c038c808cb2a23e210c2a3 to your computer and use it in GitHub Desktop.
const checkIsUploadingState = (state: State) =>
state.tag === 'Uploading';
const checkIsNewState = (a: State, b: State) =>
a.tag === b.tag;
const epic: Epic<Action, Action, State> = (
action$,
state$
) => {
const stateEntry$ = state$.distinctUntilChanged(
checkIsNewState
);
const uploadingStateEntry$ = stateEntry$.filter(
checkIsUploadingState
);
const uploadRequest$ = uploadingStateEntry$.mergeMap(
upload
);
// … return actions based on request
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment