Make the Popups, MobileFrontend, and MinervaNeue JSDocs consistent. For Popups, specify package.json, readme, and default template options and moved doc/ to docs/ and autogenerated JavaScript documentation from doc/autogenerated to docs/js. http://usejsdoc.org/about-configuring-jsdoc.html http://usejsdoc.org/about-commandline.html http://usejsdoc.org/about-configuring-default-template.html Bug: T188261 Change-Id: I81e64f06265f1ecc4e2ee159deef9b204ea7e957
1.3 KiB
Change Listeners
Redux's Store#subscribe
allows you to subscribe to updates to the state tree. These updates are
delivered every time an action is dispatched to the store, which may or may not
result in a change of state.
In the Extension:Popups codebase, a change listener is a function that is only called when the state tree has changed. As such, change listeners are predominantly responsible for updating the UI so that it matches the state in the store.
Registering Change Listeners
Change listeners are registered automatically during
boot in the registerChangeListeners
function. It expects the values of the mw.popups.changeListeners
map to be
factory functions that accept, currently, the bound action
creators, i.e.
mw.popups.changeListeners.foo = function ( boundActions ) {
var $link = $( '<a>' )
.attr( 'href': '#' )
.click( boundActions.showSettings );
return function ( prevState, state ) {
// ...
}
};
You'll note that the above change listener is effectful and maintains some
local state ($link
), both of which are acceptable. The former is unavoidable
and the latter is to avoid populating the state tree with unimportant data.