rxjs#BehaviorSubject JavaScript Examples

The following examples show how to use rxjs#BehaviorSubject. 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 vote down vote up
// 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 vote down vote up
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: generic-service.js    From ark-funds-monitor with GNU Affero General Public License v3.0 5 votes vote down vote up
tickerSubject = new BehaviorSubject('')
Example #4
Source File: generic-service.js    From ark-funds-monitor with GNU Affero General Public License v3.0 5 votes vote down vote up
errorMessageSubject = new BehaviorSubject('')
Example #5
Source File: generic-service.js    From ark-funds-monitor with GNU Affero General Public License v3.0 5 votes vote down vote up
mostActiveDaysRangeSubject = new BehaviorSubject(7)
Example #6
Source File: generic-service.js    From ark-funds-monitor with GNU Affero General Public License v3.0 5 votes vote down vote up
candlestickDaysRangeSubject = new BehaviorSubject(30)
Example #7
Source File: user.service.js    From next-js-11-basic-authentication-example with MIT License 5 votes vote down vote up
userSubject = new BehaviorSubject(process.browser && JSON.parse(localStorage.getItem('user')))
Example #8
Source File: user.service.js    From next-js-11-jwt-authentication-example with MIT License 5 votes vote down vote up
userSubject = new BehaviorSubject(process.browser && JSON.parse(localStorage.getItem('user')))
Example #9
Source File: user.service.js    From next-js-11-registration-login-example with MIT License 5 votes vote down vote up
userSubject = new BehaviorSubject(process.browser && JSON.parse(localStorage.getItem('user')))
Example #10
Source File: account.service.js    From react-facebook-login-example with MIT License 5 votes vote down vote up
accountSubject = new BehaviorSubject(null)
Example #11
Source File: account.service.js    From react-signup-verification-boilerplate with MIT License 5 votes vote down vote up
userSubject = new BehaviorSubject(null)