Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vis/requesting] only call when actually requesting #14017

Merged
merged 3 commits into from Sep 22, 2017

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Sep 15, 2017

Was talking with @nreese and learned that vis.requesting() is being called in multiple places because the hook is actually triggered on serialization, which happens multiple times in some cases. This makes the relationship between vis.requesting() and the search source more explicit by adding a dataSource.onRequestStart() hook which is called before any courier request is started.

@spalger spalger added Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc review v6.0.0 v6.1.0 v7.0.0 labels Sep 15, 2017
@spalger spalger force-pushed the fix-requesting branch 3 times, most recently from 1a1fa17 to b4fae2b Compare September 16, 2017 04:30
Copy link
Contributor

@nreese nreese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -41,7 +53,7 @@ describe('SegmentedRequestProvider', () => {

function mockSource() {
return {
get: sinon.stub().returns(mockIndexPattern())
get: sinon.stub().returns(mockIndexPattern()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the extra comma here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a line below it at one point and deleted it later

Copy link
Contributor

@stacey-gammon stacey-gammon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense and is an improvement.

$scope.searchSource.onRequestStart(() => {
return $scope.vis.requesting();
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can be shortened to $scope.searchSource.onRequestStart($scope.vis.requesting);?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Calling vis.requesting without it's this context might work, but seems like an unnecessary risk.


return Promise
.map(this._requestStartHandlers, fn => fn(this, request))
.then(_.noop);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come you need this .then(_.noop) part?

Copy link
Contributor Author

@spalger spalger Sep 22, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documented the method as returning Promise<undefined> and realized that it was actually returning Promise<Array<WhateverStartHandlersReturn>>, so I used _.noop to actually resolve to undefined.

@spalger spalger merged commit b0dc246 into elastic:master Sep 22, 2017
spalger added a commit that referenced this pull request Sep 22, 2017
* [vis/requesting] only call when actually requesting

* [courier/dataSource] use Promise.map to catch sync errors

* [courier/request] move source mutation logic out of request

(cherry picked from commit b0dc246)
spalger added a commit that referenced this pull request Sep 22, 2017
* [vis/requesting] only call when actually requesting

* [courier/dataSource] use Promise.map to catch sync errors

* [courier/request] move source mutation logic out of request

(cherry picked from commit b0dc246)
@spalger
Copy link
Contributor Author

spalger commented Sep 22, 2017

6.0: ebe7590
6.x/6.1: 404e12c

@spalger spalger deleted the fix-requesting branch September 22, 2017 09:42
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Nov 20, 2017
* [vis/requesting] only call when actually requesting

* [courier/dataSource] use Promise.map to catch sync errors

* [courier/request] move source mutation logic out of request
chrisronline pushed a commit to chrisronline/kibana that referenced this pull request Dec 1, 2017
* [vis/requesting] only call when actually requesting

* [courier/dataSource] use Promise.map to catch sync errors

* [courier/request] move source mutation logic out of request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v6.0.0-rc1 v6.0.0 v6.1.0 v7.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants