Signality

repository·main·Indexed 41 days ago

https://github.com/signalityjs/signality

A collection of atomic, signal-first utilities for building reactive compositions in Angular. It abstracts common Web APIs (such as Web Storage, Web Speech, and Favicon) and Angular CDK features (like focus monitoring and input modality) into Angular Signals, providing automatic resource cleanup and SSR compatibility. Distributed via @signality/core and @signality/cdk-interop, requiring Angular v20.0.0+.

Tokens
137.2K
Snippets
416
Records
573
Agent score
50%

What's inside Signality

  1. Signality 0.5 Features and Capabilities

    main

    Signality version 0.5 is the final minor release before version 1.0. It provides a collection of approximately 76 signal-first utilities designed for Angular development.

    Key features include:

    • Chainable Modifiers: Use onKey modifiers to chain operations.
    • Throttling Options: Support for leading and trailing options in throttling utilities.
    • SSR Ready: Designed to work in Server-Side Rendering environments.
    • Type Safe: Full TypeScript support for developer productivity and safety.
  2. Signality package overview

    main

    Signality is distributed via two main packages:

    • @signality/core: Core utilities including browser APIs, element utilities, reactive helpers, and integrations for Angular router and forms.
    • @signality/cdk-interop: Specialized integration for Angular CDK, providing utilities for focus monitoring, interactivity checking, and input modality detection.
  3. SSR and Prerendering compatibility for url()

    main

    The url() signal is designed to work with Server-Side Rendering (SSR):

    • On the Server: The signal initializes using the router's url property. When using absolute: true, the origin is derived from the REQUEST token. It correctly handles reverse proxies by honoring X-Forwarded-Host and X-Forwarded-Proto.
    • During Prerendering: Since there is no active request, the origin is unknown. The signal will fall back to a relative URL and log a warning in development.

    Note: If you use absolute: true for crawler-visible metadata (like og:url), be aware that prerendered pages will contain a relative URL until they are hydrated on the client.

  4. Naming conventions for types and interfaces

    main

    To maintain consistency, follow these naming patterns for TypeScript definitions:

    • Types and Interfaces: Use PascalCase (e.g., BatteryOptions).
    • Variables, Functions, and Properties: Use camelCase (e.g., pollingInterval).
    • Configuration Objects: Append the *Options suffix (e.g., DebouncedOptions, BatteryOptions).
    • Result Structures: For utilities that return an object containing multiple signals or properties, append the *Ref suffix (e.g., BatteryRef, FullscreenRef).
  5. How Cva integrates with Angular Forms

    main

    The cva() utility provides automatic integration with the following Angular form features:

    • Reactive Forms: Compatible with FormControl, FormControlName, and FormGroup.
    • Template-Driven Forms: Compatible with ngModel.
    • Validators: Automatically synchronizes with Validators.required.
    • State Management: Automatically syncs touched, disabled, invalid, pending, dirty, and errors states.
  6. SSR Compatibility for WebNotification

    main

    The webNotification service is safe to use in Server-Side Rendering (SSR) environments. When running on the server, the signals and methods are initialized with safe defaults to prevent errors:

    • isSupported returns false.
    • permission returns 'denied'.
    • notification returns null.
    • requestPermission is a no-op async function.
    • show and close are no-op functions.