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

@tbkmusique/settings-manager

v1.0.1

Published

[![pipeline status](https://gitlab.com/tbkmusique/settings-manager/badges/master/pipeline.svg)](https://gitlab.com/tbkmusique/settings-manager/-/commits/master) [![coverage report](https://gitlab.com/tbkmusique/settings-manager/badges/master/coverage.svg)

Downloads

2

Readme

pipeline status coverage report

Tbkmusique Settings Manager

Manage your angular service settings globally easily with this simple package.

All settings defined with this package are global. This means that every service injecting the SettingsManager service can change the configuration of services with the @ServiceWithSettings decorator. This is the primary goal of this package: manage global settings.

Usage

First, import the IonicStorageModule and the SettingsModule in your AppModule:

@NgModule({
    imports: [
        IonicStorageModule.forRoot(),
        SettingsManagerModule.forRoot({key: '__settings__'})
    ]
})
class AppModule {}

The key options defines the storage key of the settings in the ionic storage interface.

Then, for a service which needs settings:

@Injectable(...)
@ServiceWithSettings({
    myService: {
        a: 1, // 1 is default value
    }
})
class MyService {
    constructor(private settingsManager: SettingsManager){
        this.settingsManager.get().subscribe(settings=>{
            console.log(settings);
        });
    }
}

Important: you should always namespace your service settings since all services settings will be merged together.

How it works

The package ServiceManager will first merge all the settings passed to decorator @ServiceWithSettings to a single object which will be the default config. You can access the default config with the ServiceManager.defaultConfig property.

When you call get(), the ServiceManager will merge the default config with the value in the storage and return the value.

When you call set(), the ServiceManager will merge the default config, the value in storage and the argument of set(). It will storage the merged object and return it.

API

SettingsManager

Methods

set(settings: ServiceSettings): Observable<ServiceSettings>

Set a settings value. Do not forget to namespace your settings!

Example:

settingsManager.set({ myService: {a:1} }).subscribe(settings=>{
    console.log(settings); // settings.myService.a == 1
});
get(): Observable<ServiceSettings>

Get the settings.

Example:

settingsManager.get().subscribe(settings=>{
    console.log(settings); // settings.myService.a == 1
});

Properties

defaultSettings: ServiceSettings

Object containing all the default settings.

$ready: Observable<ServiceSettings>

An observable which resolves when the SettingsManager is ready to use.

storageKey: string

Storage key of the settings in the Ionic storage. It is the same as the key options in the NgModule options.