Skip to content

Commit 88b4356

Browse files
committed
Update factory method
1 parent 9fce397 commit 88b4356

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ myModule.config(function ($provide) {
311311

312312
In the code above we use the `config` callback in order to define new "provider". Provider is an object, which has a method called `$get`. Since in JavaScript we don't have interfaces and the language is duck-typed there is a convention to name the factory method of the providers this way.
313313

314-
Each service, filter, directive and controller has a provider (i.e. object which factory method), which is responsible for creating the component's instance.
314+
Each service, filter, directive and controller has a provider (i.e. object which factory method, called `$get`), which is responsible for creating the component's instance.
315315

316316
We can dig a little bit deeper in AngularJS's implementation:
317317

@@ -363,11 +363,10 @@ From the example above we can notice how the `$get` method is actually used:
363363
instanceInjector.invoke(provider.$get, provider, undefined, servicename)
364364
```
365365

366-
The snippet above calls the `invoke` method with the factory method (i.e. `$get`) of given service. Inside `invoke`'s body `annotate` is called with first argument the factory method. Annotate resolves all dependencies through the dependency injection mechanism of AngularJS. When all dependencies are resolved the factory method is being called: `fn.apply(self, args)`.
366+
The snippet above calls the `invoke` method of `instanceInjector` with the factory method (i.e. `$get`) of given service, as first argument. Inside `invoke`'s body `annotate` is called with first argument the factory method. Annotate resolves all dependencies through the dependency injection mechanism of AngularJS. When all dependencies are resolved the factory method is being called: `fn.apply(self, args)`.
367367

368368
If we think in terms of the UML diagram above we can call the provider a "ConcreteCreator" and the actual component, which is being created a "Product".
369369

370-
371370
### Composite
372371

373372
>The composite pattern is a partitioning design pattern. The composite pattern describes that a group of objects are to be treated in the same way as a single instance of an object. The intent of a composite is to "compose" objects into tree structures to represent part-whole hierarchies.

0 commit comments

Comments
 (0)