UNPKG

@rws-framework/client

Version:

This package provides the core client-side framework for Realtime Web Suit (RWS), enabling modular, asynchronous web components, state management, and integration with backend services. It is located in `.dev/client`.

24 lines (18 loc) 702 B
import getSWContainer from './_sw_container'; import type { SWContainer } from './_sw_container'; export default abstract class RWSSWService { _RELOADABLE: boolean = false; constructor() {} /** * Returns the singleton instance of this service, creating and registering it * in the SW container the first time it is called. */ public static getSingleton<T extends RWSSWService>(this: new (...args: any[]) => T): T { const key = (this as any).name as string; const container: SWContainer = getSWContainer(); if (!container.has(key)) { container.register<T>(key, new this()); } return container.get<T>(key)!; } }