Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lb(fix): remove multiple component binding sugar #619

Merged
merged 2 commits into from
Feb 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it mean app.controller no longer takes in an array of controller ctor?

Copy link
Contributor Author

@shimks shimks Feb 13, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It never did in the first place. The change is being made to a WIP PR that got accidentally merged, and since that feature (registration of array of controllers) is no longer being implemented, I'm reverting that portion of the PR.

```
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]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we eventually get rid of app.servers() (the plural version) for consistency? It's out of scope of this pull request though.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that would be a good idea ... at least till we have plans to re-visit multi-server support.

```
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