-
Notifications
You must be signed in to change notification settings - Fork 386
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we eventually get rid of There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 | ||
|
@@ -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. | ||
|
||
|
There was a problem hiding this comment.
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?There was a problem hiding this comment.
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.