npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dynamic-filtering/core

v1.0.3

Published

Dynamic Filtering core is the base of dynamic filtering that provides classes, interfaces and services for managing filters in applications. It allows developers to create and apply filters dynamically, enabling the addition, removal, and modification of

Downloads

9

Readme

Dynamic filtering core 🔎

Dynamic Filtering core is the base of dynamic filtering that provides classes, interfaces and services for managing filters in applications. It allows developers to create and apply filters dynamically, enabling the addition, removal, and modification of filters at runtime. The package supports building complex filter logic that is useful for data querying, search functionalities, and user-defined filtering rules.

Features include:

  • Classes and Interfaces: A base set of classes and interfaces for common filters supporting extension with your implementation.
  • Services: Manage filter states, listen to changes, and programmatically add new filters.

Installing ⬇️

npm install @dynamic-filtering/core

Usage 🕑

The FilterManagerService is the starting point for adding, removing, replacing and reseting your defined and to be defined filters. Using it is pretty easy. You only need to provide the initial filters (active or inactive ones).

const filters: Filter<unknown, Operation>[] = [
    new SingleSelectFilter("country", "Country", [
        new SelectOption("NL", 1),
        new SelectOption("BE", 2),
        new SelectOption("DE", 3),
        new SelectOption("CZ", 4),
        new SelectOption("PO", 5),
        new SelectOption("US", 6),
        new SelectOption("GB", 7),
    ]),
    new NumberRangeFilter("price", "Price"),
    new DateRangeFilter("startdate", "Start date"),
    new StringOperationFilter("name", "Name"),
];

const filterManagerService: FilterManagerService = new FilterManagerService(
    filters,
);

The manager service exposes useful properties like the currently active filters and conditions. Hooking into changes to these properties is pretty easy by utilizing Observables. Listening to these changes might look something as follows:

constructor(protected readonly filterManagerService: FilterManagerService) {
        this.filterManagerService.activeConditions$
            .pipe(takeUntil(this.destroy$))
            .subscribe((conditions: Condition<unknown, Operation>[]) => {
                // Do something with the active conditions (For example make an api request)
            });
    }

Angular example:

constructor(protected readonly filterManagerService: FilterManagerService) {
        this.activeConditions = toSignal(
            this.filterManagerService.activeConditions$,
            { initialValue: [] },
        );

        effect(() => {
            const activeConditions = this.activeConditions();
            // Do something with the active conditions (For example make an api request)
        });
    }

Extension 🧩

Dynamic filtering core is based on several abstractions which allow you to extend the current filter type set with your own inplementation. Want to know more about the available abstractions and how to extend the current filter type set? Click here.

Copyright and license

Code is released under the MIT License.