mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
renaming service property $creation to $eager
see changelog diff for more info
This commit is contained in:
parent
3ea5941f0e
commit
1430c6d6b1
4 changed files with 13 additions and 11 deletions
|
|
@ -5,7 +5,7 @@
|
|||
not needed.
|
||||
|
||||
### 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
|
||||
lazily initialized (e.g. $cookie, $location), as well as remove 'magic' and reduce unnecessary
|
||||
scope namespace pollution.
|
||||
|
|
@ -34,6 +34,9 @@
|
|||
this.$invalidWidgets = this.$inject('$invalidWidgets');
|
||||
}, {$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) #
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ function createInjector(providerScope, providers, cache) {
|
|||
* none: same as object but use providerScope as place to publish.
|
||||
*/
|
||||
return function inject(value, scope, args){
|
||||
var returnValue, provider, creation;
|
||||
var returnValue, provider;
|
||||
if (isString(value)) {
|
||||
if (!cache.hasOwnProperty(value)) {
|
||||
provider = providers[value];
|
||||
|
|
@ -55,13 +55,12 @@ function createInjector(providerScope, providers, cache) {
|
|||
returnValue = value.apply(scope, concat(returnValue, arguments, 2));
|
||||
} else if (isObject(value)) {
|
||||
foreach(providers, function(provider, name){
|
||||
creation = provider.$creation;
|
||||
if (creation == 'eager') {
|
||||
if (provider.$eager)
|
||||
inject(name);
|
||||
} else {
|
||||
if (isDefined(creation))
|
||||
throw "Unknown $creation value '" + creation + "' for service " + name;
|
||||
}
|
||||
|
||||
if (provider.$creation)
|
||||
throw new Error("Failed to register service '" + name +
|
||||
"': $creation property is unsupported. Use $eager:true or see release notes.");
|
||||
});
|
||||
} else {
|
||||
returnValue = inject(providerScope);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
var URL_MATCH = /^(file|ftp|http|https):\/\/(\w+:{0,1}\w*@)?([\w\.-]*)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/,
|
||||
HASH_MATCH = /^([^\?]*)?(\?([^\?]*))?$/,
|
||||
DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp':21},
|
||||
EAGER = 'eager';
|
||||
EAGER = true;
|
||||
|
||||
function angularServiceInject(name, fn, inject, eager) {
|
||||
angularService(name, fn, {$inject:inject, $creation:eager});
|
||||
angularService(name, fn, {$inject:inject, $eager:eager});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ describe('injector', function(){
|
|||
|
||||
it('should autostart eager services', function(){
|
||||
var log = '';
|
||||
providers('eager', function(){log += 'eager;'; return 'foo'}, {$creation: 'eager'});
|
||||
providers('eager', function(){log += 'eager;'; return 'foo'}, {$eager: true});
|
||||
inject();
|
||||
expect(log).toEqual('eager;');
|
||||
expect(inject('eager')).toBe('foo');
|
||||
|
|
|
|||
Loading…
Reference in a new issue