A Note on TwThemes Reactivity

The TwThemes object represents an additional piece of application state, of which certain aspects can change. It contains four pieces of state:

  • Two are non-changing static resources:
  • Two are dynamic resources that can change:
    • the activeThemeName
    • the activeInvertShade indicator

In spite of the fact that the last two resources can change, tw-themes provides no means by which this reactivity can be tracked ... other than the app module which stimulated it's change.

The reason for this is simple: There is only one place where this state is needed and used ... that is the app's UI component that manages Theme Selection. This is assumed to be true in an overwhelming majority of cases. The unique thing about this fact is that this component controls both the display and update of this state. As a result it can easily manage the reactivity, because it knows when it changes.

Consequently, tw-themes uses the KISS Principle so as not to complicate matters.

If your application is an exception to this rule, you can easily wrap TwThemes in the state management solution of your choosing to promote it's reactivity.

Future Consideration: Provide Reactivity through DOM Event

results matching ""

    No results matching ""