batching.js (954B)
1 /* This Source Code Form is subject to the terms of the Mozilla Public 2 * License, v. 2.0. If a copy of the MPL was not distributed with this 3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 4 5 "use strict"; 6 7 const { 8 BATCH_ACTIONS, 9 BATCH_ENABLE, 10 BATCH_RESET, 11 BATCH_FLUSH, 12 } = require("resource://devtools/client/netmonitor/src/constants.js"); 13 14 /** 15 * Process multiple actions at once as part of one dispatch, and produce only one 16 * state update at the end. This action is not processed by any reducer, but by a 17 * special store enhancer. 18 */ 19 function batchActions(actions) { 20 return { 21 type: BATCH_ACTIONS, 22 actions, 23 }; 24 } 25 26 function batchEnable(enabled) { 27 return { 28 type: BATCH_ENABLE, 29 enabled, 30 }; 31 } 32 33 function batchReset() { 34 return { 35 type: BATCH_RESET, 36 }; 37 } 38 39 function batchFlush() { 40 return { 41 type: BATCH_FLUSH, 42 }; 43 } 44 45 module.exports = { 46 batchActions, 47 batchEnable, 48 batchReset, 49 batchFlush, 50 };