.mergeMap(() => concat$( of$(actions.requestArticleList()), fromPromise$(Articles.getList()) .map(actions.receiveArticleList) .catch(e => of$(actions.receiveArticleList(e)) ) ))
.flatMap(res => concat( of(getEntriesSuccess( res.response, shouldRenderNewEntries( store.getState().pagination.page, store.getState().api.entries, store.getState().polling.entries, ), )), of(scrollToEntry(getScrollToId(res.response.entries, scrollTo))), ),
.mergeMap(({ payload: url }) => { if (shouldUseCachedArticle(store.getState(), url)) { return Promise.resolve().then(() => actions.useCachedArticle(url)) } return concat$( of$(actions.requestArticle()), fromPromise$( Promise.all([Articles.getList(), Articles.get(url)]) ) .map(([items, markdown]) => { const [next, prev] = createNextAndPrev(items, url) return actions.receiveArticle({ markdown, url, next, prev }, url) }) .catch(error => of$(actions.receiveArticle(error, url)) ) ) })
.switchMap(() => { const { pagination, polling, config } = store.getState(); const entries = Object.keys(polling.entries).map(key => polling.entries[key]); const pages = Math.max(pagination.pages, polling.pages); if (pagination.page === 1) { return concat( of(mergePollingIntoEntries(entries, pages)), of(scrollToEntry(`id_${entries[entries.length - 1].id}`)), ); } return getEntries(1, config, polling.newestEntry) .timeout(10000) .flatMap(res => concat( of(getEntriesSuccess(res.response, true)), of(scrollToEntry(`id_${polling.newestEntry.id}`)), )) .catch(error => of(getEntriesFailed(error))); });
.flatMap(res => concat( of(getEntriesSuccess(res.response, true)), of(scrollToEntry(`id_${polling.newestEntry.id}`)), ))