initTwThemes(schema, themes, [initialThemeName], [initialInvertShade]): TwThemes

The initTwThemes() function is the entry point into tw-themes. It initializes the utility for use in your application, and must be invoked very early in the application startup lifecycle (typically in a module scoped context).

Once the application has fully loaded (via the window load event), the initialThemeName/initialInvertShade will be activated automatically. This allows the application to manage this initial state (for example in the browser's local storage).

In essence initTwThemes() is an object creator. It returns the TwThemes object, from which from which all remaining tw-themes API is promoted. This is done so as to fuse the relationship between the Schema and Themes.

The TwThemes object contains functions to:

NOTE: These TwThemes methods are in reality functions (not methods). In other words, they can be used without dereferencing the object at run-time. The object wrapper (in this case) is simply a delivery mechanism.

NOTE: For additional considerations regarding the TwThemes object, please refer to the discussions on App State and TwThemes Reactivity.


+ initTwThemes(schema, themes, [initialThemeName], [initialInvertShade]): TwThemes


  • schema: Schema - the app-specific color schema, defining all Context Colors.

  • themes: Themes - the structure defining one or more named color themes supported by this application. This applies real colors to the context colors specified in the app's Schema.

  • initialThemeName: {string} - the initial themeName to use at app startup.

    DEFAULT: The first theme in the themes reference.

  • initialInvertShade: {boolean} - the initial invertShade option to use at app startup.

    DEFAULT: false

Return: TwThemes - a TwThemes object, from which from which all remaining tw-themes API is promoted.

results matching ""

    No results matching ""