rxjs/operators#concatAll TypeScript Examples

The following examples show how to use rxjs/operators#concatAll. 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: user-home.component.ts    From App with MIT License 6 votes vote down vote up
private shouldBlurEmote(emote: EmoteStructure): Observable<boolean> {
		return scheduled([
			emote.hasVisibility('HIDDEN'),
			emote.hasVisibility('PRIVATE')
		], asyncScheduler).pipe(
			concatAll(),
			toArray(),
			mergeMap(b => iif(() => b[0] === true || b[1] === true,
				this.clientService.hasPermission('EDIT_EMOTE_ALL').pipe(
					take(1),
					switchMap(bypass => iif(() => bypass,
						of(false),
						emote.getOwnerID().pipe(
							map(ownerID => ownerID !== this.clientService.id)
						)
					))
				),
				of(false)
			)),
			take(1)
		);
	}
Example #2
Source File: grafana.service.ts    From models-web-app with Apache License 2.0 6 votes vote down vote up
public getDasbhboardUrlFromUri(uri: string): Observable<string> {
    return this.withServiceInitialized().pipe(
      map(_ => this.dashboardUris),
      concatAll(),
      map(uris => {
        if (!(uri in uris)) {
          const msg = `Grafana URI '${uri}' does not exist in list of known URIs`;
          throw msg;
        }

        return uris[uri].url;
      }),
    );
  }
Example #3
Source File: mockApiRx.ts    From guardian with Apache License 2.0 6 votes vote down vote up
MockApiRx = of({
  ...acalaRpc,
  consts: {
    prices: { stableCurrencyFixedPrice: 1e18 },
    currencies: { getNativeCurrencyId: ACA },
    cdpEngine: {
      getStableCurrencyId: AUSD,
      collateralCurrencyIds: COLLATERAL_CURRENCY_IDS
    }
  },
  query: {
    auctionManager: {
      collateralAuctions: {
        entries: () => of([[collateralAuctionsKey(0), COLLATERAL_AUCTION]])
      }
    },
    auction: {
      auctionsIndex: () => of(registry.createType('AuctionId', 1)),
      auctions: () => of(AUCTION)
    },
    dex: {
      liquidityPool: () => of(LP)
    },
    loans: {
      positions: () => of(POSITION)
    },
    cdpEngine: {
      debitExchangeRate: () => of(EXCHANGE_RATE)
    },
    acalaOracle: {
      values: () => {
        return merge([of(PRICE), timer(1000).pipe(mapTo(PRICE_UPDATED))]).pipe(concatAll(), share());
      }
    }
  },
  createType: (type: string, value: any) => registry.createType(type, value)
})
Example #4
Source File: chatterino-dialog.component.ts    From App with MIT License 5 votes vote down vote up
ngOnInit(): void {
		scheduled([
			this.restService.createRequest<ChatterinoDialogComponent.ChatterinoVersion>('get', '/chatterino/version/win/stable', {}, 'v2').pipe(
				RestService.onlyResponse(),
				map(res => {
					this.windowsDownloads.push(
						{ label: 'INSTALLER', url: res.body?.download ?? '' },
						{ label: 'PORTABLE / STANDALONE EXE', url: res.body?.portable_download ?? '' }
					);

					return {
						label: 'Windows', icon: 'windows', svgIcon: true,
						menu: this.installTypeMenu
					} as ChatterinoDialogComponent.PlatformIcon;
				})
			),

			this.restService.createRequest<ChatterinoDialogComponent.ChatterinoVersion>('get', '/chatterino/version/linux/stable', {}, 'v2').pipe(
				RestService.onlyResponse(),
				map(res => ({
					label: 'Linux', icon: 'linux', svgIcon: true,
					url: res.body?.download
				} as ChatterinoDialogComponent.PlatformIcon))
			),

			this.restService.createRequest<ChatterinoDialogComponent.ChatterinoVersion>('get', '/chatterino/version/macos/stable', {}, 'v2').pipe(
				RestService.onlyResponse(),
				map(res => ({
					label: 'MacOS', icon: 'apple', svgIcon: true,
					url: res.body?.download
				}))
			)
		], asapScheduler).pipe(
			concatAll()
		).subscribe({
			next: p => this.platforms.push(p)
		});

		this.platforms.push(
			{
				label: 'Nightly Build',
				icon: 'nightlight',
				url: 'https://github.com/SevenTV/chatterino7/releases/tag/nightly-build'
			}
		);
	}
Example #5
Source File: user-home.component.ts    From App with MIT License 5 votes vote down vote up
ngOnInit(): void {
		this.user.pipe(
			filter(user => !!user && AppComponent.isBrowser.getValue()),
			takeUntil(this.destroyed),
			tap(user => this.currentUser = user),
			tap(user => this.emoteSlots.next(user.getSnapshot()?.emote_slots ?? 0)),

			switchMap(user => user.getAuditEntries().pipe(
				tap(entries => this.auditEntries = entries),
				mapTo(user)
			)),
			switchMap(user => user.isLive().pipe(
				map(live => this.isLive.next(live)),
				switchMap(() => user.getBroadcast()),
				map(broadcast => this.broadcast.next(broadcast)),
				mapTo(user)
			)),
			switchMap(user => scheduled([
				user.getEmotes().pipe(map(emotes => ({ type: 'channel', emotes }))),
				user.getOwnedEmotes().pipe(map(emotes => ({ type: 'owned', emotes })))
			], asapScheduler).pipe(
				concatAll(),
				mergeMap(s => from(s.emotes).pipe(
					mergeMap(em => this.shouldBlurEmote(em).pipe(map(blur => ({ blur, emote: em })))),
					map(x => x.blur ? this.blurred.add(x.emote.getID()) : noop()),
					toArray(),
					mapTo(s)
				)),
				take(2),
			))
		).subscribe({
			next: set => {
				switch (set.type) {
					case 'channel':
						this.channelEmotes = set.emotes;
						this.channelCount.next(set.emotes.length);
						break;
					case 'owned':
						this.ownedEmotes = set.emotes;
						this.ownedCount.next(set.emotes.length);
						break;
				}
			}
		});
	}
Example #6
Source File: user.component.ts    From App with MIT License 5 votes vote down vote up
ngOnInit(): void {
		this.route.paramMap.pipe(
			takeUntil(this.destroyed),
			map(params => params.get('user') as string),
			switchMap(id => this.restService.v2.GetUser(id, {
				includeEditors: true,
				includeEditorIn: true,
				includeOwnedEmotes: true,
				includeFullEmotes: true,
				includeAuditLogs: true,
				includeStreamData: true
			}, ['banned', 'youtube_id']).pipe(
				map(res => this.dataService.add('user', res.user)[0])
			)),
			tap(user => this.user.next(user)),
			switchMap(user => scheduled([
				user.getEditors().pipe(map(editors => this.editors.next(editors))),
				user.getEditorIn().pipe(map(edited => this.edited.next(edited))),
				user.getYouTubeID().pipe(tap(ytid => this.hasYouTube.next(ytid !== null)), switchMapTo(EMPTY))
			], asyncScheduler).pipe(concatAll(), mapTo(user))),
			tap(user => {
				const appURL = this.document.location.host + this.router.serializeUrl(this.router.createUrlTree(['/users', String(user.id)]));

				this.appService.pageTitleAttr.next([ // Update page title
					{ name: 'User', value: user.getSnapshot()?.display_name ?? '' }
				]);
				const roleName = user.getSnapshot()?.role?.name;
				const roleColor = user.getSnapshot()?.role?.color;
				const emoteCount = user.getSnapshot()?.emotes.length;
				const maxEmoteCount = user.getSnapshot()?.emote_slots;
				const displayName = user.getSnapshot()?.display_name ?? '';
				this.metaService.addTags([
					// { name: 'og:title', content: this.appService.pageTitle },
					// { name: 'og:site_name', content: this.appService.pageTitle },
					{ name: 'og:description', content: `${displayName} is${!!roleName ? ` ${roleName}` : ''} on 7TV with ${emoteCount}/${maxEmoteCount} emotes enabled`},
					{ name: 'og:image', content: user.getSnapshot()?.profile_image_url ?? '' },
					{ name: 'og:image:type', content: 'image/png' },
					{ name: 'theme-color', content: (roleColor ? `#${roleColor.toString(16)}` : '#fff') }
				]);

				if (!AppComponent.isBrowser.getValue()) {
					const link = this.document.createElement('link');
					link.setAttribute('type', 'application/json+oembed');

					const query = new URLSearchParams();
					query.append('object', Buffer.from(JSON.stringify({
						title: this.appService.pageTitle,
						author_name: displayName,
						author_url: `https://${appURL}`,
						provider_name: `7TV.APP - It's like a third party thing`,
						provider_url: 'https://7tv.app'
					})).toString('base64'));
					link.setAttribute('href', `https://${environment.origin}/services/oembed?` + query.toString());
					this.document.head.appendChild(link);
				}
			})
		).subscribe({
			error: (err) => this.loggerService.error('Couldn\'t fetch user', err)
		});
	}
Example #7
Source File: SyntheticPoolsTask.ts    From guardian with Apache License 2.0 5 votes vote down vote up
private getPoolIds(ethereumApi: EthereumApi, poolId: string | string[]) {
    if (poolId === 'all') {
      return ethereumApi.synthetic.allPoolIds().pipe(concatAll());
    }
    return from(castArray(poolId));
  }