From 4093e6b9d4c230ffeaedd55d3f3956fbf7e5e22f Mon Sep 17 00:00:00 2001 From: shimks Date: Tue, 13 Feb 2018 13:12:56 -0500 Subject: [PATCH 1/2] lb(fix): remove multiple component binding sugar --- pages/en/lb4/Application.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/pages/en/lb4/Application.md b/pages/en/lb4/Application.md index a46de7877..d31c70888 100644 --- a/pages/en/lb4/Application.md +++ b/pages/en/lb4/Application.md @@ -154,9 +154,10 @@ export class MyApplication extends RestApplication { #### Components ```ts -app.component([MyComponent, RestComponent]); +app.component(MyComponent); +app.component(RestComponent); ``` -The components collection allows bulk binding of component constructors within +The components collection allows binding of component constructors within your `Application` instance's context. For more information on how to make use of components, @@ -164,10 +165,10 @@ see [Using Components](Using-components.html). #### Controllers ```ts -app.controller([FooController, BarController]); +app.controller(FooController); +app.controller(BarController); ``` -Much like the components collection, the controllers collection allows bulk -binding of [Controllers](Controllers.html) to +Much like the components collection, the controllers collection allows binding of [Controllers](Controllers.html) to the `Application` context. #### Servers From 52f0e44e7c290105b86499659ff8f7349f9f0b2e Mon Sep 17 00:00:00 2001 From: shimks Date: Tue, 13 Feb 2018 13:48:56 -0500 Subject: [PATCH 2/2] fix wording --- pages/en/lb4/Application.md | 70 +++++++++++++++++++------------------ 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/pages/en/lb4/Application.md b/pages/en/lb4/Application.md index d31c70888..e7bea3197 100644 --- a/pages/en/lb4/Application.md +++ b/pages/en/lb4/Application.md @@ -124,40 +124,12 @@ In the above example: - injection calls for `repositories.widget` will be handled by a singleton instance of the `WidgetRepository` class. -### Constructor configuration - -The `Application` class constructor also accepts an -[`ApplicationConfig`](http://apidocs.strongloop.com/@loopback%2fcore/#ApplicationConfig) -object which contains component-level configurations such as -[`RestServerConfig`](http://apidocs.strongloop.com/@loopback%2frest/#RestServerConfig). -It will automatically create bindings for these configurations and later be injected -through dependency injections. Visit [Dependency Injection](Dependency-injection.html) -for more details. - -{% include note.html content=" - Binding configuration such as component binding, provider binding, or binding scopes - are not possible with the constructor-based configuration approach. -" %} - -```ts -export class MyApplication extends RestApplication { - constructor() { - super({ - rest: { - port: 4000, - host: 'my-host' - } - }) - } -} -``` - #### Components ```ts app.component(MyComponent); app.component(RestComponent); ``` -The components collection allows binding of component constructors within +The `component` function allows binding of component constructors within your `Application` instance's context. For more information on how to make use of components, @@ -168,15 +140,17 @@ see [Using Components](Using-components.html). app.controller(FooController); app.controller(BarController); ``` -Much like the components collection, the controllers collection allows binding of [Controllers](Controllers.html) to -the `Application` context. +Much like the component function, the `controller` function allows +binding of [Controllers](Controllers.html) to the `Application` context. #### Servers ```ts -app.server([MyServer, GrpcServer]); +app.server(RestServer); +app.servers([MyServer, GrpcServer]); ``` -The servers collection is also like the previous collections and allows -bulk binding of [Servers](Server.html). +The `server` function is much like the previous functions, but +with [Servers](server.html) bulk bindings are possible through the function +`servers`. ```ts const app = new Application(); @@ -186,6 +160,34 @@ app.server(RestServer, 'private'); // {'private': RestServer} In the above example, the two server instances would be bound to the Application context under the keys `servers.public`, and `servers.private` respectively. +### Constructor configuration + +The `Application` class constructor also accepts an +[`ApplicationConfig`](http://apidocs.strongloop.com/@loopback%2fcore/#ApplicationConfig) +object which contains component-level configurations such as +[`RestServerConfig`](http://apidocs.strongloop.com/@loopback%2frest/#RestServerConfig). +It will automatically create bindings for these configurations and later be injected +through dependency injections. Visit [Dependency Injection](Dependency-injection.html) +for more details. + +{% include note.html content=" + Binding configuration such as component binding, provider binding, or binding scopes + are not possible with the constructor-based configuration approach. +" %} + +```ts +export class MyApplication extends RestApplication { + constructor() { + super({ + rest: { + port: 4000, + host: 'my-host' + } + }) + } +} +``` + ## Tips for application setup Here are some tips to help avoid common pitfalls and mistakes.