renaming service property $creation to $eager

see changelog diff for more info
This commit is contained in:
Igor Minar 2011-01-04 10:40:34 -08:00
parent 3ea5941f0e
commit 1430c6d6b1
4 changed files with 13 additions and 11 deletions

View file

@ -5,7 +5,7 @@
not needed. not needed.
### Breaking changes ### Breaking changes
- Support for 'eager-published' services was removed. This change was done to make explicit - Support for `eager-published` services was removed. This change was done to make explicit
dependency declaration always required in order to allow making relatively expensive services dependency declaration always required in order to allow making relatively expensive services
lazily initialized (e.g. $cookie, $location), as well as remove 'magic' and reduce unnecessary lazily initialized (e.g. $cookie, $location), as well as remove 'magic' and reduce unnecessary
scope namespace pollution. scope namespace pollution.
@ -34,6 +34,9 @@
this.$invalidWidgets = this.$inject('$invalidWidgets'); this.$invalidWidgets = this.$inject('$invalidWidgets');
}, {$creation: 'eager'}); }, {$creation: 'eager'});
- In the light of the `eager-published` change, to complete the cleanup we renamed `$creation`
property of services to `eager` with its value being a boolean.
To transition, please rename all `$creation: 'eager'` declarations to `$eager: true`
# <angular/> 0.9.8 astral-projection (2010-12-23) # # <angular/> 0.9.8 astral-projection (2010-12-23) #

View file

@ -37,7 +37,7 @@ function createInjector(providerScope, providers, cache) {
* none: same as object but use providerScope as place to publish. * none: same as object but use providerScope as place to publish.
*/ */
return function inject(value, scope, args){ return function inject(value, scope, args){
var returnValue, provider, creation; var returnValue, provider;
if (isString(value)) { if (isString(value)) {
if (!cache.hasOwnProperty(value)) { if (!cache.hasOwnProperty(value)) {
provider = providers[value]; provider = providers[value];
@ -55,13 +55,12 @@ function createInjector(providerScope, providers, cache) {
returnValue = value.apply(scope, concat(returnValue, arguments, 2)); returnValue = value.apply(scope, concat(returnValue, arguments, 2));
} else if (isObject(value)) { } else if (isObject(value)) {
foreach(providers, function(provider, name){ foreach(providers, function(provider, name){
creation = provider.$creation; if (provider.$eager)
if (creation == 'eager') {
inject(name); inject(name);
} else {
if (isDefined(creation)) if (provider.$creation)
throw "Unknown $creation value '" + creation + "' for service " + name; throw new Error("Failed to register service '" + name +
} "': $creation property is unsupported. Use $eager:true or see release notes.");
}); });
} else { } else {
returnValue = inject(providerScope); returnValue = inject(providerScope);

View file

@ -1,10 +1,10 @@
var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/, var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/,
HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/, HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/,
DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21}, DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21},
EAGER = 'eager'; EAGER = true;
function angularServiceInject(name, fn, inject, eager) { function angularServiceInject(name, fn, inject, eager) {
angularService(name, fn, {$inject:inject, $creation:eager}); angularService(name, fn, {$inject:inject, $eager:eager});
} }
/** /**

View file

@ -53,7 +53,7 @@ describe('injector', function(){
it('should autostart eager services', function(){ it('should autostart eager services', function(){
var log = ''; var log = '';
providers('eager', function(){log += 'eager;'; return 'foo'}, {$creation: 'eager'}); providers('eager', function(){log += 'eager;'; return 'foo'}, {$eager: true});
inject(); inject();
expect(log).toEqual('eager;'); expect(log).toEqual('eager;');
expect(inject('eager')).toBe('foo'); expect(inject('eager')).toBe('foo');