Class

NgxMediaService

NgxMediaService~NgxMediaService()

Constructor

# new NgxMediaService()

The NgxMediaService provides utilities for observing and managing media-related features such as color scheme detection, window resize events, and dynamic SVG injection. It leverages Angular's dependency injection system and RxJS for reactive programming.

Service for managing media-related features in an Angular application.

View Source lib/services/NgxMediaService.ts, line 25

Example
// Inject the service into a component
constructor(private mediaService: NgxMediaService) {}

// Observe the current color scheme
this.mediaService.colorScheme$.subscribe(scheme => {
  console.log('Current color scheme:', scheme);
});

// Observe window resize events
this.mediaService.resize$.subscribe(dimensions => {
  console.log('Window dimensions:', dimensions);
});

Members

# _document

This getter provides access to the global document object, ensuring it is properly typed.

Retrieves the global document object.

View Source lib/services/NgxMediaService.ts, line 116

# _window

This getter provides access to the global window object, ensuring it is properly typed.

Retrieves the global window object.

View Source lib/services/NgxMediaService.ts, line 106

# angularZone

This service is used to optimize performance by running certain operations outside Angular's zone and bringing updates back into the zone when necessary.

Angular's NgZone service for running code outside Angular's zone.

View Source lib/services/NgxMediaService.ts, line 71

# colorScheme$

This observable emits the current color scheme (light or dark) and updates whenever the system's color scheme preference changes or the DARK_PALETTE_CLASS is toggled.

Observable that emits the current color scheme of the application.

View Source lib/services/NgxMediaService.ts, line 91

Observable.<WindowColorScheme>

# colorScheme$

This observable emits the current color scheme (light or dark) and updates whenever the system's color scheme preference changes or the DARK_PALETTE_CLASS is toggled.

Observable that emits the current color scheme of the application.

View Source lib/services/NgxMediaService.ts, line 427

# currentSchema

This property holds the current color scheme (light, dark, or undefined) and is updated whenever the color scheme changes.

Tracks the current color scheme of the application.

View Source lib/services/NgxMediaService.ts, line 84

# destroy$

This subject is used to complete observables and clean up resources when the service is destroyed. It is utilized with the takeUntil operator to manage subscriptions.

Subject used to signal the destruction of the service.

View Source lib/services/NgxMediaService.ts, line 54

# resize$

This observable emits the current dimensions of the window (width and height) and updates whenever the window is resized.

Observable that emits the current dimensions of the window.

View Source lib/services/NgxMediaService.ts, line 98

Observable.<IWindowResizeEvent>

# resize$

This observable emits the current dimensions of the window (width and height) and updates whenever the window is resized.

Observable that emits the current dimensions of the window.

View Source lib/services/NgxMediaService.ts, line 435

# resizeSubject

This subject holds the current dimensions of the window (width and height) and emits updates whenever the window is resized. It is used to provide the resize$ observable.

BehaviorSubject to track the window's dimensions.

View Source lib/services/NgxMediaService.ts, line 61