Socket
Socket
Sign inDemoInstall

ngx-fi-styles-loader

Package Overview
Dependencies
8
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ngx-fi-styles-loader

A streamlined approach to load styles dynamically


Version published
Maintainers
1
Install size
337 kB
Created

Readme

Source

NgxFiStylesLoader

A streamlined approach to load styles dynamically

Installation

  • npm i lodash --save
  • npm i @types/lodash --save-dev
  • npm i ngx-fi-lodash --save
  • npm i ngx-fi-styles-loader --save

How to use

In a module

import { NgModule } from "@angular/core";
import { NgxFiStylesLoaderModule } from "ngx-fi-styles-loader";

@NgModule({
  imports: [NgxFiStylesLoaderModule], // for consumption within the scope of the module
  exports: [NgxFiStylesLoaderModule] // if propagation is required
})
export class SomeModule {}

Where required

import { StyleHandlingMode, StylesLoaderService } from "ngx-fi-styles-loader";

export class SomeClass {
  constructor(private loaderService: StylesLoaderService) {}
}

For testing

import { NgxFiStylesLoaderTestingModule, StylesLoaderMockService, StylesLoaderService } from "ngx-fi-styles-loader";

describe('TestingTitle', () => {
  let stylesLoaderService: StylesLoaderMockService;
  beforeEach(async(() => {
      TestBed.configureTestingModule({
        imports: [NgxFiStylesLoaderTestingModule]
      });

      stylesLoaderService = TestBed.get(StylesLoaderService);
    }));
  }));
}));

Notes

  • components:

    • StylesLoaderComponent / styles-loader: to be used when managed loading of styles is required
    • StylesLoaderRawComponent / styles-loader-raw: to be used when un-managed loading of styles is required
  • enums:

    • StyleHandlingMode
    • PassThrough: just passes the url to be loaded
    • VerifiedPassThrough: downloads content first, passed the url to be loaded on success
    • Literal: downloads the content and passes it as an object url; should not be used when stylesheet contains any relative paths referencing assets
  • services:

    • StylesLoaderService: used in conjuction with StylesLoaderComponent to load styles; in addition, info regarding the loading status of a style(s) are provided

      export interface IStylesLoaderService {
        loadingStyles$: Observable<{ [key: string]: string }>;
      
        isStyleLoading(url: string): boolean;
      
        isStyleLoading$(url: string): Observable<boolean>;
      
        areStylesLoading(urls: string[]): boolean;
      
        areStylesLoading$(urls: string[]): Observable<boolean>;
      
        getStyle$(url: string, styleHandlingMode?: StyleHandlingMode): Observable<string>;
      }
      

Keywords

FAQs

Last updated on 07 Apr 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc