How to use the rxjs/operators.filter function in rxjs

To help you get started, we’ve selected a few rxjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudfoundry / stratos / src / frontend / app / shared / components / cf-role-checkbox / cf-role-checkbox.component.ts View on Github external
ngOnInit() {
    this.isOrgRole = !this.spaceGuid;
    const users$ = this.store.select(selectUsersRolesPicked);
    // Org? Org manager. Space? Org manager or space manager
    const canEditRole$ = this.isOrgRole ?
      this.userPerms.can(CurrentUserPermissions.ORGANIZATION_CHANGE_ROLES, this.cfGuid, this.orgGuid) :
      canUpdateOrgSpaceRoles(
        this.userPerms,
        this.cfGuid,
        this.orgGuid,
        this.spaceGuid);

    this.sub = this.cfRolesService.existingRoles$.pipe(
      combineLatest(this.cfRolesService.newRoles$, users$, canEditRole$),
      filter(([existingRoles, newRoles, users, canEditRole]) => !!users.length && !!newRoles.orgGuid)
    ).subscribe(([existingRoles, newRoles, users, canEditRole]) => {
      this.orgGuid = newRoles.orgGuid;
      if (this.role) {
        console.log(existingRoles, newRoles);
        // TODO: RC existingRoles needs to have newly assigned roles... this list comes from users in a pagination section...
      }
      const { checked, tooltip } = CfRoleCheckboxComponent.getCheckedState(
        this.role, users, existingRoles, newRoles, this.orgGuid, this.spaceGuid);
      this.checked = checked;
      this.tooltip = tooltip;
      this.disabled = !canEditRole ||
        CfRoleCheckboxComponent.isDisabled(this.isOrgRole, this.role, users, existingRoles, newRoles, this.orgGuid, checked);
    });
  }
github lordfriend / Deneb-UI / src / timeline-meter / timeline-meter.ts View on Github external
ngAfterViewInit(): void {
        let meterEl = this.meter.nativeElement;
        let container = this.container.nativeElement;
        let renderWrapper = this.renderWrapper.nativeElement;
        // for mouse event
        this._subscription.add(
            observableFromEvent(meterEl, 'mousedown').pipe(
                filter(() => {
                    return this.timestampList && this.timestampList.length > 0;
                }),
                mergeMap((event: MouseEvent) => {
                    event.preventDefault();
                    return observableFromEvent(document, 'mousemove').pipe(
                        takeUntil(observableFromEvent(document, 'mouseup')));
                }),
                map((event: MouseEvent) => {
                    return Math.max(0, Math.min(event.clientY - renderWrapper.getBoundingClientRect().top, this.availableHeight));
                }),)
                .subscribe((pos: number) => {
                    this.scrollTo(pos);
                })
        );

        // for click
github cloudfoundry / stratos / src / frontend / packages / core / src / features / cloud-foundry / user-invites / user-invite.service.ts View on Github external
constructor(
    private store: Store,
    private http: HttpClient,
    private snackBar: MatSnackBar,
    cfEndpointService: CloudFoundryEndpointService,
    private currentUserPermissionsService: CurrentUserPermissionsService,
    private activeRouteCfOrgSpace: ActiveRouteCfOrgSpace,
    private confirmDialog: ConfirmationDialogService,
  ) {
    this.configured$ = cfEndpointService.endpoint$.pipe(
      filter(v => !!v && !!v.entity),
      // Note - metadata could be falsy if smtp server not configured/other metadata properties are missing
      map(v => v.entity.metadata && v.entity.metadata.userInviteAllowed === 'true')
    );

    this.canConfigure$ = combineLatest(
      waitForCFPermissions(this.store, this.activeRouteCfOrgSpace.cfGuid),
      this.store.select('auth')
    ).pipe(
      map(([cf, auth]) =>
        cf.global.isAdmin &&
        auth.sessionData['plugin-config'] && auth.sessionData['plugin-config'].userInvitationsEnabled === 'true')
    );
  }
github rabix / composer / src / app / tool-editor / object-inspector / input-inspector / basic-section / basic-input-section.component.ts View on Github external
ngAfterViewInit() {
        merge(
            of(this.includeInCommandLine.length),
            this.includeInCommandLine.changes.pipe(
                map(l => l.length)
            )
        ).pipe(
            distinctUntilChanged(),
            filter(a => !!a)
        ).subscribeTracked(this, () => {
            this.addIncludeInCommandLineToggleDecorator();
        });
    }
}
github cloudfoundry / stratos / src / frontend / app / shared / components / list / list-types / github-commits / github-commits-list-config-app-tab.service.ts View on Github external
private setDeployedCommitDetails() {
    this.store.select(
      selectEntity>(githubCommitSchemaKey, this.projectName + '-' + this.deployedCommitSha))
      .pipe(
        filter(deployedCommit => !!deployedCommit),
        first(),
        map(deployedCommit => deployedCommit.entity)
      ).subscribe(deployedCommit => {
        this.deployedCommit = deployedCommit;
        this.deployedTime = moment(this.deployedCommit.commit.author.date).unix();
      });
  }
github SchweizerischeBundesbahnen / scion-workbench / projects / scion / workbench-application-platform / src / lib / core / app-outlet.directive.ts View on Github external
public requestReply(message: HostMessage): Promise {
    const replyToUid = UUID.randomUUID();

    const reply$ = this._messageBus.receiveReplyMessagesForApplication$(this.symbolicName)
      .pipe(
        filter(env => env.replyToUid === replyToUid),
        first(),
        takeUntil(this._destroy$),
        map(env => env.message),
      );

    const request: MessageEnvelope = {
      protocol: PROTOCOL,
      channel: 'host',
      sender: this.symbolicName,
      replyToUid: replyToUid,
      message: message,
    };
    this._site.postMessage(request);

    return reply$.toPromise();
  }
github berta-cms / berta / editor / src / app / shop / shop-state.service.ts View on Github external
exhaustMap(() => {
              return this.store.select(state => state.user).pipe(
                pairwise(),
                filter(([prevUser, user]) => !!user.token && prevUser.token !== user.token),
                take(1));
            })
          );
github synyi / poplar / src / Annotator / View / Element / HardLine.ts View on Github external
constructor(public store: Sentence,
                parent: TextBlock) {
        super(parent);
        this.store.destructed$.pipe(first())
            .subscribe(() => this.destructor());
        this.storeTextChangedSubscription = this.store.textChanged$
            .subscribe(() => this.rerender());
        Store.labelAdded$.pipe(
            filter((label: Label) => {
                return this.store.globalStartIndex <= label.startIndex && label.endIndex <= this.store.globalEndIndex;
            }),
            filter((label: Label) => {
                for (let softline of this.children) {
                    if (softline.globalStartIndex <= label.startIndex && label.endIndex <= softline.globalEndIndex) {
                        return false;
                    }
                }
                return true;
            })).subscribe(() => this.rerender());
    }
github sanity-io / sanity / packages / @sanity / document-store / src / createDocumentStore.js View on Github external
function createBufferedDocument(documentId, serverEvents$, doCommit) {
  const bufferedDocument = createObservableBufferedDocument(serverEvents$, doCommit)

  const reconnects$ = serverEvents$.pipe(filter(event => event.type === 'reconnect'))

  return {
    events: merge(reconnects$, bufferedDocument.updates$),
    patch(patches) {
      bufferedDocument.addMutations(patches.map(patch => ({patch: {...patch, id: documentId}})))
    },
    create(document) {
      bufferedDocument.addMutation({
        create: Object.assign({id: documentId}, document)
      })
    },
    createIfNotExists(document) {
      bufferedDocument.addMutation({createIfNotExists: document})
    },
    createOrReplace(document) {
      bufferedDocument.addMutation({createOrReplace: document})
github Alfresco / alfresco-ng2-components / lib / process-services-cloud / src / lib / people / components / people-cloud.component.ts View on Github external
filterUsersByRoles(user: IdentityUserModel): Observable {
        return this.identityUserService.checkUserHasRole(user.id, this.roles).pipe(
            map((hasRole: boolean) => ({ hasRole: hasRole, user: user })),
            filter((filteredUser: { hasRole: boolean, user: IdentityUserModel }) => filteredUser.hasRole),
            map((filteredUser: { hasRole: boolean, user: IdentityUserModel }) => filteredUser.user));
    }