Skip to content

Instantly share code, notes, and snippets.

tap(() => (
dispatch(
pong(),
)
)),
ignoreElements(),
const pingEpic = (
action$,
) => (
action$
.pipe(
ofType(CREATE_PING_LISTENER)
mergeMap(({
namespace,
}) => (
action$
const dispatchOnError = (
actionCreator,
returnValue,
) => (
catchError((
error,
) => {
dispatch(
actionCreator(
error,
const fetchUserEpic = (
action$,
state$,
{ dispatch },
) => (
action$
.pipe(
ofType(FETCH_USER),
tap(() => {
dispatch(
const fetchUserEpic = action$ => (
action$.pipe(
ofType(FETCH_USER),
switchMap(({ username, password }) => (
merge(
of(setLoading('login')),
ajax.getJSON('https://api.example.com/login').pipe(
switchMap(({ authToken }) => of(
fetchUserSucceeded(authToken),
setLoaded('login'),
const fetchUserEpic = (
action$,
) => (
action$
.pipe(
ofType(FETCH_USER),
switchMap(({
password,
username,
}) => (
const someEpic = (
action$,
) => (
action$
.pipe(
ofType(FETCH_DATA),
switchMap(() => (
ajax('/data')
.pipe(
switchMap((
const someEpic = (
action$,
store,
) => (
action$
.pipe(
ofType(FETCH_DATA),
switchMap(() => (
ajax('/data')
.pipe(
@Sawtaytoes
Sawtaytoes / README.md
Created September 27, 2019 14:44
Comparison of item storage techniques

The goal of this Gist is to figure out which items storage technique is a best-practice or good recommendation for taking a list of items and storing them into an asynchronous data storage.

There are various goals to accomplish such as reducing indirection, creating distinct micro-epics (each with their own job), and having an overall simpler time maintaining the code.

I've put together 2 examples of how you might handle storing a list of items with epics. A third example was added to show what one of the versions would look like with the ability to know when those items are done storing.

@Sawtaytoes
Sawtaytoes / App.svelte
Last active October 16, 2019 07:40
Hello world
<script>
import { createStore } from './fakeRedux.js'
let count = 0
const stateModifiers = {
DECREMENT: () => {
count -= 1
},
INCREMENT: () => {