[openstack-dev] [Horizon] Angular action services and initScope
Richard Jones
r1chardj0n3s at gmail.com
Fri Jul 15 20:28:58 UTC 2016
Hi folks,
Something that's been bothering me for a while is that the action services
break the encapsulation model of Angular Services - that they are
singletons, and consumable by multiple simultaneous consumers without those
consumers affecting each other through their use of the Service.
At the moment the initScope() functionality we've included in the action
services breaks that model - at a minimum it is possible for multiple
consumers to initScope() with different scopes simultaneously. This is the
reason why I've been arguing (ok, "debating" :-) for the cessation of using
scopes in this way.
I think we need to do two things reasonably soon (before patterns become
more ingrained):
1. Stop passing in $scope to initScope in all cases - the new
ActionResult-enabled pattern should hopefully replace all those
2. Remove all initScope methods altogether. The only other use of initScope
that I see is the pre-loading of data used during the execution of action
allowed() methods. We should move that preloading/caching either into the
creation of the Service object itself, or into the allowed method.
If there is a use-case of initScope that I've missed (something that needs
to be execute *after* the Service is created, not something that needs to
tie the Service to a particular consumer of the service) then please let me
know :-)
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstack.org/pipermail/openstack-dev/attachments/20160715/31a2b555/attachment.html>
More information about the OpenStack-dev
mailing list