Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342483 - Function to get multiple services
Summary: Function to get multiple services
Status: RESOLVED WONTFIX
Alias: None
Product: Orion
Classification: ECD
Component: Client (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Simon Kaegi CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-11 14:08 EDT by John Arthorne CLA
Modified: 2015-05-05 14:47 EDT (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description John Arthorne CLA 2011-04-11 14:08:17 EDT
We typically have a coding pattern like this:

serviceReg.getService("SomeService").then(function(service) {
  service.doSomething();
});

If you need two services you need something like:

serviceReg.getService("SomeService").then(function(service) {
  serviceReg.getService("AnotherService").then(function(another) {
    service.doSomethingWith(another);
  });
});

It would be nice if the service registry had a convenience for doing something that requires multiple services at once:

serviceReg.getServices("SomeService", "AnotherService").then(function(service, another) {
    service.doSomethingWith(another);
});
Comment 1 Simon Kaegi CLA 2011-04-11 14:19:14 EDT
This pattern is so common, I wonder if we should be using a DeferredList or something along those lines more regularly instead of putting this in our implementation.
Comment 2 Boris Bokowski CLA 2011-04-11 15:42:11 EDT
I wouldn't add to much convenience around this. Ideally, all the "getting a service" calls should be in a top-level JavaScript file that gets the services needed on a particular page, and just passes the service instance instead of the service registry.
Comment 3 John Arthorne CLA 2011-04-11 21:24:46 EDT
(In reply to comment #2)
> I wouldn't add to much convenience around this. Ideally, all the "getting a
> service" calls should be in a top-level JavaScript file that gets the services
> needed on a particular page, and just passes the service instance instead of
> the service registry.

That sounds like exactly the kind of scenario where you need a "get several" function. Say a given page needs ten services. The "glue code" script that gathers all those services is going to be ugly without some kind of helper. Currently our "glue code" scripts are bypassing the service registry and manually instantiating all the services, so we don't see the problem yet.
Comment 4 John Arthorne CLA 2015-05-05 14:47:52 EDT
Closing as part of a mass clean up of inactive bugs. Please reopen if this problem still occurs or is relevant to you. For more details see:

https://dev.eclipse.org/mhonarc/lists/orion-dev/msg03444.html