Skip to content
This repository was archived by the owner on Jun 4, 2024. It is now read-only.

Remove events #114

Merged
merged 12 commits into from
Jan 21, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
251 changes: 101 additions & 150 deletions dash_renderer/dash_renderer.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -33420,9 +33420,9 @@ function symbolObservablePonyfill(root) {
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = function() {
throw new Error("define cannot be used indirect");
};
module.exports = function() {
throw new Error("define cannot be used indirect");
};


/***/ }),
Expand All @@ -33434,26 +33434,26 @@ module.exports = function() {
/*! no static exports found */
/***/ (function(module, exports) {

var g;

// This works in non-strict mode
g = (function() {
return this;
})();

try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1, eval)("this");
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}

// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}

module.exports = g;
var g;
// This works in non-strict mode
g = (function() {
return this;
})();
try {
// This works if eval is allowed (see CSP)
g = g || Function("return this")() || (1, eval)("this");
} catch (e) {
// This works if the window reference is available
if (typeof window === "object") g = window;
}
// g can still be undefined, but nothing to do about it...
// We return undefined, instead of nothing here, so it's
// easier to handle this case. if(!global) { ...}
module.exports = g;


/***/ }),
Expand All @@ -33465,28 +33465,28 @@ module.exports = g;
/*! no static exports found */
/***/ (function(module, exports) {

module.exports = function(module) {
if (!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};
module.exports = function(module) {
if (!module.webpackPolyfill) {
module.deprecate = function() {};
module.paths = [];
// module.parent = undefined by default
if (!module.children) module.children = [];
Object.defineProperty(module, "loaded", {
enumerable: true,
get: function() {
return module.l;
}
});
Object.defineProperty(module, "id", {
enumerable: true,
get: function() {
return module.i;
}
});
module.webpackPolyfill = 1;
}
return module;
};


/***/ }),
Expand Down Expand Up @@ -34777,50 +34777,43 @@ function reduceInputIds(nodeIds, InputGraph) {
function notifyObservers(payload) {
return function (dispatch, getState) {
var id = payload.id,
event = payload.event,
props = payload.props,
excludedOutputs = payload.excludedOutputs;

var _getState2 = getState(),
graphs = _getState2.graphs,
requestQueue = _getState2.requestQueue;

var EventGraph = graphs.EventGraph,
InputGraph = graphs.InputGraph;
var InputGraph = graphs.InputGraph;
/*
* Figure out all of the output id's that depend on this
* event or input.
* Figure out all of the output id's that depend on this input.
* This includes id's that are direct children as well as
* grandchildren.
* grandchildren will get filtered out in a later stage.
*/

var outputObservers = void 0;
if (event) {
outputObservers = EventGraph.dependenciesOf(id + '.' + event);
} else {
var changedProps = (0, _ramda.keys)(props);
outputObservers = [];
changedProps.forEach(function (propName) {
var node = id + '.' + propName;
if (!InputGraph.hasNode(node)) {
return;
var outputObservers = [];

var changedProps = (0, _ramda.keys)(props);
changedProps.forEach(function (propName) {
var node = id + '.' + propName;
if (!InputGraph.hasNode(node)) {
return;
}
InputGraph.dependenciesOf(node).forEach(function (outputId) {
/*
* Multiple input properties that update the same
* output can change at once.
* For example, `n_clicks` and `n_clicks_previous`
* on a button component.
* We only need to update the output once for this
* update, so keep outputObservers unique.
*/
if (!(0, _ramda.contains)(outputId, outputObservers)) {
outputObservers.push(outputId);
}
InputGraph.dependenciesOf(node).forEach(function (outputId) {
/*
* Multiple input properties that update the same
* output can change at once.
* For example, `n_clicks` and `n_clicks_previous`
* on a button component.
* We only need to update the output once for this
* update, so keep outputObservers unique.
*/
if (!(0, _ramda.contains)(outputId, outputObservers)) {
outputObservers.push(outputId);
}
});
});
}
});

if (excludedOutputs) {
outputObservers = (0, _ramda.reject)((0, _ramda.flip)(_ramda.contains)(excludedOutputs), outputObservers);
Expand Down Expand Up @@ -34862,11 +34855,7 @@ function notifyObservers(payload) {
* this loop hits C because of the overallOrder sorting logic
*/

/*
* if the output just listens to events, then it won't be in
* the InputGraph
*/
var controllers = InputGraph.hasNode(outputIdAndProp) ? InputGraph.dependantsOf(outputIdAndProp) : [];
var controllers = InputGraph.dependantsOf(outputIdAndProp);

var controllersInFutureQueue = (0, _ramda.intersection)(queuedObservers, controllers);

Expand Down Expand Up @@ -34938,7 +34927,7 @@ function notifyObservers(payload) {

var requestUid = newRequestQueue[i].uid;

promises.push(updateOutput(outputComponentId, outputProp, event, getState, requestUid, dispatch));
promises.push(updateOutput(outputComponentId, outputProp, getState, requestUid, dispatch));
}

/* eslint-disable consistent-return */
Expand All @@ -34947,7 +34936,7 @@ function notifyObservers(payload) {
};
}

function updateOutput(outputComponentId, outputProp, event, getState, requestUid, dispatch) {
function updateOutput(outputComponentId, outputProp, getState, requestUid, dispatch) {
var _getState3 = getState(),
config = _getState3.config,
layout = _getState3.layout,
Expand All @@ -34958,51 +34947,39 @@ function updateOutput(outputComponentId, outputProp, event, getState, requestUid
var InputGraph = graphs.InputGraph;

/*
* Construct a payload of the input, state, and event.
* Construct a payload of the input and state.
* For example:
* If the input triggered this update, then:
* {
* inputs: [{'id': 'input1', 'property': 'new value'}],
* state: [{'id': 'state1', 'property': 'existing value'}]
* }
*
* If an event triggered this udpate, then:
* {
* state: [{'id': 'state1', 'property': 'existing value'}],
* event: {'id': 'graph', 'event': 'click'}
* }
*
*/

var payload = {
output: { id: outputComponentId, property: outputProp }
};

if (event) {
payload.event = event;
}

var _dependenciesRequest$ = dependenciesRequest.content.find(function (dependency) {
return dependency.output.id === outputComponentId && dependency.output.property === outputProp;
}),
inputs = _dependenciesRequest$.inputs,
state = _dependenciesRequest$.state;

var validKeys = (0, _ramda.keys)(paths);
if (inputs.length > 0) {
payload.inputs = inputs.map(function (inputObject) {
// Make sure the component id exists in the layout
if (!(0, _ramda.contains)(inputObject.id, validKeys)) {
throw new ReferenceError('An invalid input object was used in an ' + '`Input` of a Dash callback. ' + 'The id of this object is `' + inputObject.id + '` and the property is `' + inputObject.property + '`. The list of ids in the current layout is ' + '`[' + validKeys.join(', ') + ']`');
}
var propLens = (0, _ramda.lensPath)((0, _ramda.concat)(paths[inputObject.id], ['props', inputObject.property]));
return {
id: inputObject.id,
property: inputObject.property,
value: (0, _ramda.view)(propLens, layout)
};
});
}

payload.inputs = inputs.map(function (inputObject) {
// Make sure the component id exists in the layout
if (!(0, _ramda.contains)(inputObject.id, validKeys)) {
throw new ReferenceError('An invalid input object was used in an ' + '`Input` of a Dash callback. ' + 'The id of this object is `' + inputObject.id + '` and the property is `' + inputObject.property + '`. The list of ids in the current layout is ' + '`[' + validKeys.join(', ') + ']`');
}
var propLens = (0, _ramda.lensPath)((0, _ramda.concat)(paths[inputObject.id], ['props', inputObject.property]));
return {
id: inputObject.id,
property: inputObject.property,
value: (0, _ramda.view)(propLens, layout)
};
});

if (state.length > 0) {
payload.state = state.map(function (stateObject) {
// Make sure the component id exists in the layout
Expand Down Expand Up @@ -35457,13 +35434,6 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
dependencies: stateProps.dependencies,
paths: stateProps.paths,

fireEvent: function fireEvent(_ref) {
var event = _ref.event;

// Update this component's observers with the updated props
dispatch((0, _actions.notifyObservers)({ event: event, id: ownProps.id }));
},

setProps: function setProps(newProps) {
var payload = {
props: newProps,
Expand All @@ -35480,19 +35450,13 @@ function mergeProps(stateProps, dispatchProps, ownProps) {
};
}

function NotifyObserversComponent(_ref2) {
var children = _ref2.children,
id = _ref2.id,
paths = _ref2.paths,
dependencies = _ref2.dependencies,
fireEvent = _ref2.fireEvent,
setProps = _ref2.setProps;

var thisComponentTriggersEvents = dependencies && dependencies.find(function (dependency) {
return dependency.events.find(function (event) {
return event.id === id;
});
});
function NotifyObserversComponent(_ref) {
var children = _ref.children,
id = _ref.id,
paths = _ref.paths,
dependencies = _ref.dependencies,
setProps = _ref.setProps;

var thisComponentSharesState = dependencies && dependencies.find(function (dependency) {
return dependency.inputs.find(function (input) {
return input.id === id;
Expand All @@ -35501,19 +35465,17 @@ function NotifyObserversComponent(_ref2) {
});
});
/*
* Only pass in `setProps` and `fireEvent` if they are actually
* necessary.
* This allows component authors to skip computing data
* for `setProps` or `fireEvent` (which can be expensive)
* in the case when they aren't actually used.
* Only pass in `setProps` if necessary.
* This allows component authors to skip computing unneeded data
* for `setProps`, which can be expensive.
* For example, consider `hoverData` for graphs. If it isn't
* actually used, then the component author can skip binding
* the events for the component.
*
* TODO - A nice enhancement would be to pass in the actual events
* and properties that are used into the component so that the
* component author can check for something like `subscribed_events`
* or `subscribed_properties` instead of `fireEvent` and `setProps`.
* TODO - A nice enhancement would be to pass in the actual
* properties that are used into the component so that the
* component author can check for something like
* `subscribed_properties` instead of just `setProps`.
*/
var extraProps = {};
if (thisComponentSharesState &&
Expand All @@ -35525,9 +35487,6 @@ function NotifyObserversComponent(_ref2) {
paths[id]) {
extraProps.setProps = setProps;
}
if (thisComponentTriggersEvents && paths[id]) {
extraProps.fireEvent = fireEvent;
}

if (!(0, _ramda.isEmpty)(extraProps)) {
return _react2.default.cloneElement(children, extraProps);
Expand Down Expand Up @@ -36143,12 +36102,10 @@ var graphs = function graphs() {
{
var dependencies = action.payload;
var inputGraph = new _dependencyGraph.DepGraph();
var eventGraph = new _dependencyGraph.DepGraph();

dependencies.forEach(function registerDependency(dependency) {
var output = dependency.output,
inputs = dependency.inputs,
events = dependency.events;
inputs = dependency.inputs;

var outputId = output.id + '.' + output.property;
inputs.forEach(function (inputObject) {
Expand All @@ -36157,15 +36114,9 @@ var graphs = function graphs() {
inputGraph.addNode(inputId);
inputGraph.addDependency(inputId, outputId);
});
events.forEach(function (eventObject) {
var eventId = eventObject.id + '.' + eventObject.event;
eventGraph.addNode(outputId);
eventGraph.addNode(eventId);
eventGraph.addDependency(eventId, outputId);
});
});

return { InputGraph: inputGraph, EventGraph: eventGraph };
return { InputGraph: inputGraph };
}

default:
Expand Down
2 changes: 1 addition & 1 deletion dash_renderer/dash_renderer.dev.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dash_renderer/dash_renderer.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dash_renderer/dash_renderer.min.js.map

Large diffs are not rendered by default.

Loading