Skip to content

Commit

Permalink
feat(atom): add forwardSideFx() interceptor
Browse files Browse the repository at this point in the history
  • Loading branch information
postspectacular committed Mar 16, 2018
1 parent e52e7e5 commit 357c46e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/atom/src/interceptors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@ export function trace(_, e) {
console.log("event:", e);
}

/**
* Higher-order interceptor. Return interceptor which unpacks payload
* from event and assigns it as is to given side effect ID.
*
* @param id side effect ID
*/
export function forwardSideFx(id: string) {
return (_, [__, body]) => ({ [id]: body });
}

/**
* Higher-order interceptor for validation purposes. Takes a predicate
* function and an optional interceptor function, which will only be
Expand Down

0 comments on commit 357c46e

Please sign in to comment.