Bug 1200798 - refactor sources and breakpoints in debugger to use redux r=ejpbruel
This commit is contained in:
@@ -6,16 +6,21 @@
|
||||
const { promiseInvoke } = require("devtools/shared/async-utils");
|
||||
const { reportException } = require("devtools/shared/DevToolsUtils");
|
||||
|
||||
// RDP utils
|
||||
|
||||
function rdpInvoke(client, method, ...args) {
|
||||
return promiseInvoke(client, method, ...args)
|
||||
return (promiseInvoke(client, method, ...args)
|
||||
.then((packet) => {
|
||||
let { error, message } = packet;
|
||||
if (error) {
|
||||
throw new Error(error + ": " + message);
|
||||
if (packet.error) {
|
||||
let { error, message } = packet;
|
||||
const err = new Error(error + ": " + message);
|
||||
err.rdpError = error;
|
||||
err.rdpMessage = message;
|
||||
throw err;
|
||||
}
|
||||
|
||||
return packet;
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
function asPaused(client, func) {
|
||||
@@ -42,4 +47,58 @@ function asPaused(client, func) {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { rdpInvoke, asPaused };
|
||||
function handleError(err) {
|
||||
reportException("promise", err.toString());
|
||||
}
|
||||
|
||||
function onReducerEvents(controller, listeners, thisContext) {
|
||||
Object.keys(listeners).forEach(name => {
|
||||
const listener = listeners[name];
|
||||
controller.onChange(name, payload => {
|
||||
listener.call(thisContext, payload);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function _getIn(destObj, path) {
|
||||
return path.reduce(function(acc, name) {
|
||||
return acc[name];
|
||||
}, destObj);
|
||||
}
|
||||
|
||||
function mergeIn(destObj, path, value) {
|
||||
path = [...path];
|
||||
path.reverse();
|
||||
var obj = path.reduce(function(acc, name) {
|
||||
return { [name]: acc };
|
||||
}, value);
|
||||
|
||||
return destObj.merge(obj, { deep: true });
|
||||
}
|
||||
|
||||
function setIn(destObj, path, value) {
|
||||
destObj = mergeIn(destObj, path, null);
|
||||
return mergeIn(destObj, path, value);
|
||||
}
|
||||
|
||||
function updateIn(destObj, path, fn) {
|
||||
return setIn(destObj, path, fn(_getIn(destObj, path)));
|
||||
}
|
||||
|
||||
function deleteIn(destObj, path) {
|
||||
const objPath = path.slice(0, -1);
|
||||
const propName = path[path.length - 1];
|
||||
const obj = _getIn(destObj, objPath);
|
||||
return setIn(destObj, objPath, obj.without(propName));
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
rdpInvoke,
|
||||
asPaused,
|
||||
handleError,
|
||||
onReducerEvents,
|
||||
mergeIn,
|
||||
setIn,
|
||||
updateIn,
|
||||
deleteIn
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user