rxjs/operators#distinctUntilKeyChanged TypeScript Examples

The following examples show how to use rxjs/operators#distinctUntilKeyChanged. 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: app.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
accountWithHorizonQuery$ = selectPersistStateInit()
    .pipe(switchMap(() => {
      const selectedAccount$ = this.walletsAccountsQuery.getSelectedAccount$
        .pipe(filter(account => !!account))
        .pipe(distinctUntilKeyChanged('_id'));

      const selectedHorizonApi$ = this.horizonApisQuery.getSelectedHorizonApi$
        .pipe(filter(horizon => !!horizon))
        .pipe(distinctUntilKeyChanged('_id'));

      return combineLatest([
        selectedAccount$,
        selectedHorizonApi$
      ]);
    }));
Example #2
Source File: claimable-balances-dashboard.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
ngOnInit(): void {
    this.walletsAccountsQuery.getSelectedAccount$
      .pipe(distinctUntilKeyChanged('_id'))
      .pipe(filter<any>(Boolean))
      .pipe(takeUntil(this.componentDestroyed$))
      .subscribe((selectedAccount: IWalletsAccount) => {
        this.getClaimableBalancesAndAssetsData(selectedAccount);
      });
  }
Example #3
Source File: operations-dashboard.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
accountOperations$: Observable<IWalletsOperation[]> = this.selectedAccount$
    .pipe(filter(account => !!account))
    .pipe(distinctUntilKeyChanged('_id'))
    .pipe(withLatestFrom(this.settingsQuery.antiSpamPublicKeys$))
    .pipe(switchMap(([account, antiSpamPublicKeys]) => {
      return this.walletsOperationsQuery.selectAll({
        filterBy: entity => entity.ownerAccount === account._id
          && !antiSpamPublicKeys.find(key => entity.operationRecord.source_account === key),
        sortBy: (entityA, entityB) => entityB.createdAt - entityA.createdAt,
      });
    }))
    .pipe(debounceTime(10));
Example #4
Source File: operations-dashboard.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
getLatestOperationsSubscription: Subscription = this.typeOfOperationsControl.valueChanges
    .pipe(startWith('only_payments'))
    .pipe(switchMap(_ => {
      return combineLatest([
        this.selectedAccount$.pipe(distinctUntilKeyChanged('_id')),
        this.horizonApisQuery.getSelectedHorizonApi$.pipe(distinctUntilKeyChanged('_id'))
      ]);
    }))
    .pipe(takeUntil(this.componentDestroyed$))
    .pipe(switchMap(([account, horizonApi]) => {
      return this.walletsAccountsService.getLatestAccountOperations({
        account,
        horizonApi,
        onlyPayments: this.typeOfOperationsControl.value === 'only_payments',
      })
        .catch(_ => {
          this.nzMessageService.error('No operations available for this account in the Blockchain');
          return [];
        });
    }))
    .subscribe();
Example #5
Source File: claimable-balances.query.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
selectedAccountClaimableBalances$: Observable<ServerApi.ClaimableBalanceRecord[]> = this.walletsAccountsQuery.getSelectedAccount$
    .pipe(distinctUntilKeyChanged('_id'))
    .pipe(switchMap(selectedAccount => {
      if (!selectedAccount) {
        return of([]);
      }

      return this.selectAll({
        filterBy: entity => entity.accountId === selectedAccount._id,
      });
    }));
Example #6
Source File: wallets-assets.query.ts    From xBull-Wallet with GNU Affero General Public License v3.0 6 votes vote down vote up
selectedAccountAssets$ = this.walletsAccountsQuery.getSelectedAccount$
    .pipe(distinctUntilKeyChanged('_id'))
    .pipe(switchMap(selectedAccount => {
      const assetsBalances = selectedAccount.accountRecord?.balances || [];

      return this.selectAll({
        filterBy: entity => !!this.walletsAssetsService.filterBalancesLines(assetsBalances)
          .find(b => this.walletsAssetsService.formatBalanceLineId(b) === entity._id)
      });
    }));
Example #7
Source File: distinct-unique-key.operator.ts    From etherspot-sdk with MIT License 6 votes vote down vote up
/**
 * @ignore
 */
export function distinctUniqueKey<T, K extends keyof T>(key: K): OperatorFunction<T, T[K]> {
  return (input$) =>
    input$.pipe(
      map((value) => {
        return (value ? value : { [key]: null }) as T;
      }),
      distinctUntilKeyChanged(key, deepCompare),
      pluck(key),
    );
}
Example #8
Source File: send-payment.component.ts    From xBull-Wallet with GNU Affero General Public License v3.0 5 votes vote down vote up
resetFormWhenSourceAccountChangesSubscription = this.selectedAccount$
    .pipe(distinctUntilKeyChanged('_id'))
    .pipe(takeUntil(this.componentDestroyed$))
    .subscribe(() => {
      this.form.reset();
    });