Skip to content

[WIP] return promise from DataService.list #62

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

Open
wants to merge 55 commits into
base: console_1.3
Choose a base branch
from

Conversation

jwforres
Copy link
Owner

No description provided.

spadgett and others added 30 commits April 8, 2016 12:56
…stry

    - Add angular-extension-registry
        - TODO: register openshift/angular-extension-registry w/bower & update
    - Update hawtio javalink extension to new manager
    - Update online-extensions
    - Swap java console link icon to fa-share
    - Update extensions nav-system-status, nav-system-status-mobile, nav-user-dropdown
    - eliminate documtentation & about link html, register as extension in run block
    - Move logout link into extension
    - Style adjustments to needed to position utility nav links
- rename openshiftConsoleExtensions to javaLinkExtension to encourage individual module naming
- add /extensions/javalink directory to help encourage extension organization
- add hawtioPluginLoader.addModule() back to load module after openshiftConsole bootstraps
- fix missing containerStatus check
- wrap in IIFE to protect against globals
Use function declarations rather than function expressions when a
function is called before defined. This can prevent runtime errors.

(The newer jshint is catching these problems.)
URI.expand() returns a URI instance rather than a string, which causes
later errors passing query parameters in the $http config object.

https://medialize.github.io/URI.js/docs.html#static-expand
`pod-count` class is no longer used in donut title.
Warn users when navigating away with the terminal window open
Fix httpGet path in pod template
Fix usage rate calculation for network metrics in pod page
@jwforres
Copy link
Owner Author

@spadgett @liggitt first pass, just using the promise in the other resources page for the moment, but if folks are happy with the general idea then i can update the other places we are using list

@jwforres
Copy link
Owner Author

jwforres commented Apr 21, 2016

cc @benjaminapetersen


var deferred = $q.defer();
var promises = this._listPromises(resource, context);
promises.push(deferred);

Choose a reason for hiding this comment

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

How do you feel about hiding away some of the details here to make the flow a little easier:

  var key = this._uniqueKeyForResourceContext(resource, context);
  // currently we are inferring 'cached' from _watchInFlight and _resourceVersion
  if(this.cached(key)) {
    this.fireCallbacks(this._data(key));
    deferred.resolve(this._data(key));
  }

Copy link
Owner Author

Choose a reason for hiding this comment

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

agree its more readable but thats a significantly bigger refactor across this file to change all those method signatures to one param instead of two, to me its not worth the added regression risk, but I'm open to other opinions @spadgett @liggitt

i'd be ok with just adding a cached(resource, context) that does the checks for watchInFlight and resourceVersion, i think that is your biggest concern right? that its not obvious what watchInFlight && resourceVersion is actually checking.

Choose a reason for hiding this comment

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

Yeah, just making DataService as friendly as possible since its the brains behind everything. I'm good with ignoring that for later, Ill make a mental note and may PR it as a tech debt thing down the road.

@jwforres
Copy link
Owner Author

pushed some updates

@benjaminapetersen
Copy link

Cool, looks good!

@jwforres jwforres force-pushed the console_1.3 branch 2 times, most recently from 145b910 to 536125d Compare April 27, 2016 00:29
@benjaminapetersen
Copy link

benjaminapetersen commented Apr 27, 2016

Commenting about the watch/promise deal because I agree its worth tinkering a bit. Would be nice to update .watch() to look more like .get(), etc:

DataService
  .get('stuff')
  .then(function(data) {
    // yay
  }, function() {
    // boo :(
  });

DataService
  .watch('stuff')
  .event(function(evt) {
    // yay
  }, function(error) {
    // boo :(
  });

.event() seems meaningful in websocket lingo, dunno if anyone else has thoughts. The trick is just ensuring that .event() has a queue internally (like a promise) rather than just accepting a single callback.

Prob is worth investigating as a separate PR as well, though.

UPDATE: the streamer is sort of a facade for a promise as well:

DataService
  .createStream('foo')
  .onMessage(function() {
    // yay
  })
  // uh oh, deviant!
  .onError(function() {})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants