/* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict";
/** * Create and configure store for the Console panel. This is the place * where various enhancers and middleware can be registered.
*/ function configureStore(webConsoleUI, options = {}) { const prefsService = getPrefsService(webConsoleUI); const { getBoolPref, getIntPref } = prefsService;
return createStore(
createRootReducer(),
initialState,
compose(
middleware,
enableActorReleaser(webConsoleUI),
enableMessagesCacheClearing(webConsoleUI), // ⚠️ Keep this one last so it will be executed before all the other ones. This is // needed so batched actions can be "unbatched" and handled in the other enhancers.
enableBatching()
)
);
}
function createRootReducer() { returnfunction rootReducer(state, action) { // We want to compute the new state for all properties except // "messages" and "history". These two reducers are handled // separately since they are receiving additional arguments. const newState = Object.entries(reducers).reduce((res, [key, reducer]) => { if (key !== "messages" && key !== "history") {
res[key] = reducer(state[key], action);
} return res;
}, {});
// Pass prefs state as additional argument to the history reducer.
newState.history = reducers.history(state.history, action, newState.prefs);
// Specifically pass the updated filters, prefs and ui states as additional arguments.
newState.messages = reducers.messages(
state.messages,
action,
newState.filters,
newState.prefs,
newState.ui
);
return newState;
};
}
// Provide the store factory for test code so that each test is working with // its own instance.
module.exports.configureStore = configureStore;
¤ Dauer der Verarbeitung: 0.16 Sekunden
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.