Skip to content
This repository was archived by the owner on Dec 4, 2017. It is now read-only.

Commit f609b3e

Browse files
committed
midway through incorporating thso's comments...
1 parent 4660e85 commit f609b3e

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

public/docs/dart/latest/guide/dependency-injection.jade

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,17 @@ include ../_util-fns
112112
+includeShared('{ts}', 'di-service-service-2')
113113
+includeShared('{ts}', 'di-injectable-1')
114114
+includeShared('{ts}', 'di-injectable-2')
115-
115+
.callout.is-critical
116+
header Always include the parentheses
117+
:marked
118+
Always use `@Injectable()`, not just `@Injectable`.
119+
A metadata annotation must be either a reference to a
120+
compile-time constant variable or a call to a constant
121+
constructor such as `Injectable()`.
122+
If we forget the parentheses, the analyzer will complain:
123+
"Annotation creation must have arguments". If we try to run the
124+
app anyway, it won't work, and the console will say
125+
"expression must be a compile-time constant".
116126
+includeShared('{ts}', 'logger-service-1')
117127
+makeExample(
118128
'dependency-injection/dart/lib/logger_service.dart',null, 'lib/logger_service')
@@ -152,8 +162,9 @@ include ../_util-fns
152162
For that reason, you can't call functions to get values
153163
to use within an annotation.
154164
Instead, you use constant literals or constant constructors.
155-
For example, a TypeScript or JavaScript program might use
156-
`provide(Logger, {useClass: BetterLogger})` or, equivalently,
165+
For example, a TypeScript program might use the
166+
function call `provide(Logger, {useClass: BetterLogger})`,
167+
which is equivalent to the TypeScript code
157168
`new Provider(Logger, {useClass: BetterLogger})`.
158169
A Dart annotation would instead use the constant value `const Provider(Logger, useClass: BetterLogger)`.
159170
+includeShared('{ts}', 'providers-alternative-2')

public/docs/ts/latest/guide/dependency-injection.jade

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,12 +430,13 @@ include ../_util-fns
430430

431431
We *can* add it if we really want to. It isn't necessary because
432432
the `HeroesComponent` is already #{decorated} with `@Component`. #{any_decorator}
433-
434-
.alert.is-critical
433+
// #enddocregion di-injectable-2
434+
.callout.is-critical
435+
header Always include the parentheses
435436
:marked
436-
**Always include the parentheses!** Always use `@Injectable()`.
437+
Always use `@Injectable()`, not just `@Injectable`.
437438
Our application will fail mysteriously if we forget the parentheses.
438-
// #enddocregion di-injectable-2
439+
439440
// #docregion logger-service-1
440441
.l-main-section
441442
:marked
@@ -528,11 +529,14 @@ code-example(format, language="html").
528529
// #enddocregion providers-1
529530
+makeExample('dependency-injection/ts/app/providers.component.ts','providers-logger')
530531
// #docregion providers-2
532+
- var lang = current.path[1]
533+
- var implements = lang == 'dart' ? 'implements' : 'looks and behaves like a '
534+
#{decoration}
531535
:marked
532536
The `providers` array appears to hold a service class.
533537
In reality it holds an instance of the [Provider](/docs/ts/latest/api/core/Provider-class.html) class that can create that service.
534538

535-
There are many ways to *provide* something that looks and behaves like a `Logger`.
539+
There are many ways to *provide* something that #{implements} `Logger`.
536540
The `Logger` class itself is an obvious and natural provider — it has the right shape and it's designed to be created.
537541
But it's not the only way.
538542

0 commit comments

Comments
 (0)