universalviewer icon indicating copy to clipboard operation
universalviewer copied to clipboard

Global helper objects

Open LlGC-jop opened this issue 9 months ago • 1 comments

Something that came up following our discussion of config was the idea of a global Config helper object to act as a store of app config and simplify accessing it.

Something like Config.uv.animationDelay for an app-wide one or Config.OpenSeaDragon.enableDownloads for extension specifics.

As it would probably be a very large undertaking to implement app-wide we thought that a proof-of-concept in a smaller extension during this sprint might work?

The same could apply for localisation strings and possibly other elements if anyone can think of any?

I will also admit that this comes from a PHP/Laravel-centric POV, where config() and trans() functions do the same thing, so it might not be as feasible in a TypeScript application (although I don't see why not)

LlGC-jop avatar May 01 '25 14:05 LlGC-jop

I do find the idea of easier access to configs very appealing -- but we would definitely have to review how the configuration is currently processed, as I believe different configurations are read and combined on a per-module basis, so a global helper would likely need to have context incorporated somehow (unless we redesign the overall configuration strategy, which I imagine is not off the table, but which would be even more disruptive).

I have complained before about the fact that certain configurations are presently repeated in many places, and I wish that there were some kind of inheritance mechanism in play where we could set global defaults and only override non-default settings on a per-module basis. Maybe something like that could be incorporated if we have a stand-alone config helper. It's been years since I've carefully studied the config code, though, so my memory is dim and I may be speaking a certain amount of nonsense. ;-)

demiankatz avatar May 05 '25 16:05 demiankatz