Topic on User talk:Roan Kattouw (WMF)/Flow

Nirmos (talkcontribs)

Hi. I have some questions about modularization. If I want to get my own name, I can either type mw.config.values.wgUserName or mw.user.getName(), but if I want to get the page name, the only option seems to be mw.config.values.wgPageName. The only thing I can find in mw.page is watch. So, my question is, will more stuff be added to mw.page in the future? Will it be something like mw.page.getPageName() in the future? Is the work with modularization abandoned or ongoing? Will the values in mw.config.values eventually be deprecated once they've been in a module long enough? Is there a Phabricator task about this? I did find phab:T133277 which is called "Modularization of JS code", but that appears to be something much more specific than what I'm talking about.

Roan Kattouw (WMF) (talkcontribs)

Side note: you should use mw.config.get( 'wgFoo' ) instead of mw.config.values.wgFoo.

I don't think there's a specific task about this (perhaps @Timo Tijhof (WMF) would know) but an idea I've proposed before is to expose config variables per module instead of globally. This could change mw.config.get() to something else, but we'd probably keep the old one around for backwards compatibility. As for mw.page, I'm not aware of any immediate plans to move more stuff into there.

I wouldn't say the modularization work is abandoned, but it's not particularly active either. Perhaps a better way to describe its status would be "dormant" or "moving slowly". The task you found is specific to one extension (RevisionSlider).

Nirmos (talkcontribs)

Is there a reason I should use mw.config.get( 'wgFoo' ) over mw.config.values.wgFoo? mw.config.get( 'wgFoo' ) fails silently with trailing spaces, even though it is unambiguous, see this edit for instance. mw.config.values.wgFoo is much more robust and fails loudly.

Roan Kattouw (WMF) (talkcontribs)

The main reason is that mw.config.values.foo is using an internal implementation detail, not the public API. The public API is mw.config.get( 'foo' ). So the latter is considered cleaner, but both work. You're right though that louder failures for misspelled config variables would be good.

Krinkle (talkcontribs)
Reply to "Modularization"