Details
-
Story
-
Resolution: Fixed
-
Medium
-
None
-
5.2-alpha1
Description
- this.generatePromiseService can easily be a real private function, as it is only used from within the constructor
- The same is true for _capi, which may be private to the constructor as well. There is no need to expose either of those information to the outside world.
In fact there isn't actually the need for a local variable either. The provided argument to the function can easily be used. - Each time a service is requested from the PromiseCAPI it is wrapped again. As during a single session (single-page-app) services may be requested multiple times services are singletons inside the CAPI. This behaviour needs to be transfered over to the PromiseCAPI
- Instead of using string conversions for checking if something really is an array the constructor should
always be checked as checking for the string does not work in every js environment. (String identifiers are
not always the same):if ( ... && ( this._capi[key].toString().match(/^function\s*(get[^\s(]+Serv ice)/).constructor === [].constructor) { - Nevertheless in this special case this type of check should not be done at all, as changing the call order allows the usage of the ``test`` method, which is available for exactly this kind of use case:: if ( ... && (/^function\s*(get[^\s(]+Service)/).test(capi[key].toString ())) {
- The before proposed switch to direct (private) variables for all of the functions as well as the capi removes
the need to use a var that = this construct completely. It may therefore be removed. - Mostly all remarks regarding the PromiseCAPI fit for the PromiseService as well. With the exception, that no further cache storage is needed.
- Especially the remarks on the following topics should be understood with regards to this implementation
as well:
+ RegExp string check using test
+ Real private variables
+ No need for this._originalService