rename to promiseInterval
This commit is contained in:
parent
5b403ba7d1
commit
3fb35e8123
7 changed files with 15 additions and 15 deletions
|
@ -1,5 +1,5 @@
|
|||
import apiService from '../api/api.service.js'
|
||||
import { makeFetcher } from '../fetcher/fetcher.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
const fetchAndUpdate = ({ store, credentials }) => {
|
||||
return apiService.fetchFollowRequests({ credentials })
|
||||
|
@ -13,7 +13,7 @@ const fetchAndUpdate = ({ store, credentials }) => {
|
|||
const startFetching = ({ credentials, store }) => {
|
||||
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||
boundFetchAndUpdate()
|
||||
return makeFetcher(boundFetchAndUpdate, 10000)
|
||||
return promiseInterval(boundFetchAndUpdate, 10000)
|
||||
}
|
||||
|
||||
const followRequestFetcher = {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import apiService from '../api/api.service.js'
|
||||
import { makeFetcher } from '../fetcher/fetcher.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
const update = ({ store, notifications, older }) => {
|
||||
store.dispatch('setNotificationsError', { value: false })
|
||||
|
@ -61,7 +61,7 @@ const startFetching = ({ credentials, store }) => {
|
|||
setTimeout(() => store.dispatch('setNotificationsSilence', false), 10000)
|
||||
const boundFetchAndUpdate = () => fetchAndUpdate({ credentials, store })
|
||||
boundFetchAndUpdate()
|
||||
return makeFetcher(boundFetchAndUpdate, 10000)
|
||||
return promiseInterval(boundFetchAndUpdate, 10000)
|
||||
}
|
||||
|
||||
const notificationsFetcher = {
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
|
||||
// makeFetcher - replacement for setInterval for fetching, starts counting
|
||||
// the interval only after a request is done instead of immediately.
|
||||
// promiseInterval - replacement for setInterval for promises, starts counting
|
||||
// the interval only after a promise is done instead of immediately.
|
||||
// - promiseCall is a function that returns a promise, it's called the first
|
||||
// time after the first interval.
|
||||
// - interval is the interval delay in ms.
|
||||
|
||||
export const makeFetcher = (promiseCall, interval) => {
|
||||
export const promiseInterval = (promiseCall, interval) => {
|
||||
let stopped = false
|
||||
let timeout = null
|
||||
let func = () => {}
|
||||
|
@ -24,5 +24,5 @@ export const makeFetcher = (promiseCall, interval) => {
|
|||
|
||||
timeout = window.setTimeout(func, interval)
|
||||
|
||||
return stopFetcher
|
||||
return { stop: stopFetcher }
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
import { camelCase } from 'lodash'
|
||||
|
||||
import apiService from '../api/api.service.js'
|
||||
import { makeFetcher } from '../fetcher/fetcher.js'
|
||||
import { promiseInterval } from '../promise_interval/promise_interval.js'
|
||||
|
||||
const update = ({ store, statuses, timeline, showImmediately, userId, pagination }) => {
|
||||
const ccTimeline = camelCase(timeline)
|
||||
|
@ -74,7 +74,7 @@ const startFetching = ({ timeline = 'friends', credentials, store, userId = fals
|
|||
fetchAndUpdate({ timeline, credentials, store, showImmediately, userId, tag })
|
||||
const boundFetchAndUpdate = () =>
|
||||
fetchAndUpdate({ timeline, credentials, store, userId, tag })
|
||||
return makeFetcher(boundFetchAndUpdate, 10000)
|
||||
return promiseInterval(boundFetchAndUpdate, 10000)
|
||||
}
|
||||
const timelineFetcher = {
|
||||
fetchAndUpdate,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue