Skip to content

Commit

Permalink
lb(fix): remove multiple component binding sugar (#619)
Browse files Browse the repository at this point in the history
* lb(fix): remove multiple component binding sugar

* fix wording
  • Loading branch information
shimks authored and bschrammIBM committed Feb 13, 2018
1 parent 3c6844b commit 48cf128
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions pages/en/lb4/Application.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,42 @@ In the above example:
- injection calls for `repositories.widget` will be handled by a singleton
instance of the `WidgetRepository` class.

#### Components
```ts
app.component(MyComponent);
app.component(RestComponent);
```
The `component` function allows binding of component constructors within
your `Application` instance's context.

For more information on how to make use of components,
see [Using Components](Using-components.html).

#### Controllers
```ts
app.controller(FooController);
app.controller(BarController);
```
Much like the component function, the `controller` function allows
binding of [Controllers](Controllers.html) to the `Application` context.

#### Servers
```ts
app.server(RestServer);
app.servers([MyServer, GrpcServer]);
```
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();
app.server(RestServer, 'public'); // {'public': RestServer}
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
Expand Down Expand Up @@ -152,39 +188,6 @@ export class MyApplication extends RestApplication {
}
```

#### Components
```ts
app.component([MyComponent, RestComponent]);
```
The components collection allows bulk binding of component constructors within
your `Application` instance's context.

For more information on how to make use of components,
see [Using Components](Using-components.html).

#### Controllers
```ts
app.controller([FooController, BarController]);
```
Much like the components collection, the controllers collection allows bulk
binding of [Controllers](Controllers.html) to
the `Application` context.

#### Servers
```ts
app.server([MyServer, GrpcServer]);
```
The servers collection is also like the previous collections and allows
bulk binding of [Servers](Server.html).

```ts
const app = new Application();
app.server(RestServer, 'public'); // {'public': RestServer}
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.

## Tips for application setup
Here are some tips to help avoid common pitfalls and mistakes.

Expand Down

0 comments on commit 48cf128

Please sign in to comment.