Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 739100e

Browse files
ajaygmpetebacondarwin
authored andcommitted
docs($provide): document decorator method
Closes #14562
1 parent 20e0c7f commit 739100e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

src/auto/injector.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,18 +347,20 @@ function annotate(fn, strictDi, name) {
347347
* these cases the {@link auto.$provide $provide} service has additional helper methods to register
348348
* services without specifying a provider.
349349
*
350-
* * {@link auto.$provide#provider provider(provider)} - registers a **service provider** with the
350+
* * {@link auto.$provide#provider provider(name, provider)} - registers a **service provider** with the
351351
* {@link auto.$injector $injector}
352-
* * {@link auto.$provide#constant constant(obj)} - registers a value/object that can be accessed by
352+
* * {@link auto.$provide#constant constant(name, obj)} - registers a value/object that can be accessed by
353353
* providers and services.
354-
* * {@link auto.$provide#value value(obj)} - registers a value/object that can only be accessed by
354+
* * {@link auto.$provide#value value(name, obj)} - registers a value/object that can only be accessed by
355355
* services, not providers.
356-
* * {@link auto.$provide#factory factory(fn)} - registers a service **factory function**, `fn`,
356+
* * {@link auto.$provide#factory factory(name, fn)} - registers a service **factory function**
357357
* that will be wrapped in a **service provider** object, whose `$get` property will contain the
358358
* given factory function.
359-
* * {@link auto.$provide#service service(class)} - registers a **constructor function**, `class`
359+
* * {@link auto.$provide#service service(name, Fn)} - registers a **constructor function**
360360
* that will be wrapped in a **service provider** object, whose `$get` property will instantiate
361361
* a new object using the given constructor function.
362+
* * {@link auto.$provide#decorator decorator(name, decorFn)} - registers a **decorator function** that
363+
* will be able to modify or replace the implementation of another service.
362364
*
363365
* See the individual methods for more information and examples.
364366
*/
@@ -615,18 +617,20 @@ function annotate(fn, strictDi, name) {
615617
* @name $provide#decorator
616618
* @description
617619
*
618-
* Register a **service decorator** with the {@link auto.$injector $injector}. A service decorator
620+
* Register a **decorator function** with the {@link auto.$injector $injector}. A decorator function
619621
* intercepts the creation of a service, allowing it to override or modify the behavior of the
620-
* service. The object returned by the decorator may be the original service, or a new service
621-
* object which replaces or wraps and delegates to the original service.
622+
* service. The return value of the decorator function may be the original service, or a new service
623+
* that replaces (or wraps and delegates to) the original service.
624+
*
625+
* You can find out more about using decorators in the {@link guide/decorators} guide.
622626
*
623627
* @param {string} name The name of the service to decorate.
624628
* @param {Function|Array.<string|Function>} decorator This function will be invoked when the service needs to be
625-
* instantiated and should return the decorated service instance. The function is called using
629+
* provided and should return the decorated service instance. The function is called using
626630
* the {@link auto.$injector#invoke injector.invoke} method and is therefore fully injectable.
627631
* Local injection arguments:
628632
*
629-
* * `$delegate` - The original service instance, which can be monkey patched, configured,
633+
* * `$delegate` - The original service instance, which can be replaced, monkey patched, configured,
630634
* decorated or delegated to.
631635
*
632636
* @example

0 commit comments

Comments
 (0)