Skip to content

Commit

Permalink
move shouldLoad check from register to load function (#493)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienpoly authored Nov 25, 2021
1 parent 0fa2fa5 commit ab531d4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/core/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,18 @@ export class Application implements ErrorHandler {
}

register(identifier: string, controllerConstructor: ControllerConstructor) {
if ((controllerConstructor as any).shouldLoad) {
this.load({ identifier, controllerConstructor })
}
this.load({ identifier, controllerConstructor })
}

load(...definitions: Definition[]): void
load(definitions: Definition[]): void
load(head: Definition | Definition[], ...rest: Definition[]) {
const definitions = Array.isArray(head) ? head : [head, ...rest]
definitions.forEach(definition => this.router.loadDefinition(definition))
definitions.forEach(definition => {
if ((definition.controllerConstructor as any).shouldLoad) {
this.router.loadDefinition(definition)
}
})
}

unload(...identifiers: string[]): void
Expand Down

0 comments on commit ab531d4

Please sign in to comment.