rxjs/operators#delay JavaScript Examples
The following examples show how to use
rxjs/operators#delay.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KrakenExchangeClient.js From invizi with GNU General Public License v3.0 | 6 votes |
// fetch deposits AND withdrawal
getDepositsObs (apiKey, symbolCurrencyPair = undefined, params = {}) {
let counter = -1
this.initializeApiKey(apiKey)
const query = () => {
counter++
return this.ccxt.fetchLedger(undefined, undefined, undefined, {ofs: counter * 50})
}
const trades$ = defer(query)
let load$ = new BehaviorSubject('')
const whenToRefresh$ = of('').pipe(
delay(5000),
tap(_ => load$.next('')),
skip(1))
const byDepositAndWithdrawal = trade => trade && ['deposit', 'withdrawal'].includes(trade.info.type)
const poll$ = concat(trades$, whenToRefresh$)
return load$.pipe(
concatMap(_ => poll$),
takeWhile(data => data.length > 0),
map(data => ({errors: [], data: data.filter(byDepositAndWithdrawal).map(parseLedger)})),
catchError(error$ => of({errors: [error$.toString()], data: []})))
}
Example #2
Source File: KrakenExchangeClient.js From invizi with GNU General Public License v3.0 | 6 votes |
getMyTradesObs (apiKey, symbolCurrencyPair = undefined, params = {}) {
let counter = -1
this.initializeApiKey(apiKey)
const fetchTrades = () => {
counter++
return super.getMyTrades(apiKey, undefined, {ofs: counter * 50})
}
const trades$ = defer(() => fetchTrades())
let load$ = new BehaviorSubject('')
const whenToRefresh$ = of('').pipe(
delay(5000),
tap(_ => load$.next('')),
skip(1))
const poll$ = concat(trades$, whenToRefresh$)
let result$ = load$.pipe(
concatMap(_ => poll$),
takeWhile(data => data.length > 0),
map(data => ({errors: [], data})),
catchError(error$ => {
return of({errors: [error$.toString()], data: []})
}))
return result$
}
Example #3
Source File: restaurantEpic.js From git-brunching with GNU General Public License v3.0 | 5 votes |
pingEpic = (action$) => action$.pipe(
filter((action) => action.type === actionType.ADD_RESTAURANTS),
delay(1000), // Asynchronously wait 1000ms then continue
mapTo({ type: actionType.ADD_RESTAURANTS_SUCCESS, restaurants: [1, 2] }),
)