Skip to content

[idea] Make second parameter of /list an Observable, not just the inner values #389

Description

@dirkpostma

I have a list of employees. Every employee has a name and and active property, e.g.

{
   name: "Dirk Postma",
   active: true
}

In my view I'd like to be able to filter by active flag, for example:

this.filteredItems = af.database.list('employees', {
    query: {
        orderByChild: 'active',
        equalTo: this.querySubject
    }
});

toggleActiveFilter() {
   this.showActive = !this.showActive;
   this.querySubject.next(this.showActive);
}

This works, great stuff!

Now one step further: I'd like to be able to show either active employees or ALL employees (both active and inactive). I would like to have something like this:

this.filteredItems = af.database.list('employees',  this.querySubject });

toggleActiveFilter() {
    this.showActive = !this.showActive;

    if (this.showActive) {
        // Show active employees only
        this.querySubject.next({
            query: {
                orderByChild: 'active',
                equalTo: true
            }
        });
    } else {
        // show all employees
        this.querySubject.next(null);
    }
}

Basically: make the second parameter itself an Observable in stead of just the inner values of e.g. equalTo.

Is this an idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp: databaseRealtime Database (src/database).

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions