Skip to content

Commit

Permalink
fixup! perf: prefer use factory instead of use value when possible
Browse files Browse the repository at this point in the history
  • Loading branch information
H4ad committed Nov 17, 2023
1 parent 9a1ea46 commit 31a0b18
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
16 changes: 8 additions & 8 deletions integration/inspector/e2e/fixtures/post-init-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "ExternalContextCreator"
"token": "ExternalContextCreator",
"initTime": 0
}
},
"208171089": {
Expand Down Expand Up @@ -800,10 +800,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "ModulesContainer"
"token": "ModulesContainer",
"initTime": 0
}
},
"-326832201": {
Expand All @@ -816,10 +816,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "HttpAdapterHost"
"token": "HttpAdapterHost",
"initTime": 0
}
},
"-702581189": {
Expand Down Expand Up @@ -848,10 +848,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "SerializedGraph"
"token": "SerializedGraph",
"initTime": 0
}
},
"-1251270035": {
Expand Down
16 changes: 8 additions & 8 deletions integration/inspector/e2e/fixtures/pre-init-graph.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "ExternalContextCreator"
"token": "ExternalContextCreator",
"initTime": 0
}
},
"208171089": {
Expand Down Expand Up @@ -784,10 +784,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "ModulesContainer"
"token": "ModulesContainer",
"initTime": 0
}
},
"-326832201": {
Expand All @@ -800,10 +800,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "HttpAdapterHost"
"token": "HttpAdapterHost",
"initTime": 0
}
},
"-702581189": {
Expand Down Expand Up @@ -832,10 +832,10 @@
"sourceModuleName": "InternalCoreModule",
"durable": false,
"static": true,
"scope": 0,
"transient": false,
"exported": true,
"token": "SerializedGraph"
"token": "SerializedGraph",
"initTime": 0
}
},
"-1251270035": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"test:dev": "mocha -w --watch-files \"packages\" packages/**/*.spec.ts",
"pretest:cov": "npm run clean",
"test:cov": "nyc mocha packages/**/*.spec.ts --reporter spec",
"test:integration": "mocha \"integration/*/{,!(node_modules)/**/}/*.spec.ts\"",
"test:integration": "mocha --reporter-option maxDiffSize=0 \"integration/*/{,!(node_modules)/**/}/*.spec.ts\"",
"test:docker:up": "docker-compose -f integration/docker-compose.yml up -d",
"test:docker:down": "docker-compose -f integration/docker-compose.yml down",
"lint": "concurrently 'npm run lint:packages' 'npm run lint:integration' 'npm run lint:spec'",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/router/router-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export class RouterModule {
providers: [
{
provide: ROUTES,
useFactory: () => routes,
useValue: routes,
},
],
};
Expand Down
12 changes: 7 additions & 5 deletions packages/microservices/module/clients.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@ import {
export class ClientsModule {
static register(options: ClientsModuleOptions): DynamicModule {
const clientsOptions = !Array.isArray(options) ? options.clients : options;
const clients = (clientsOptions || []).map(item => ({
provide: item.name,
useFactory: () =>
this.assignOnAppShutdownHook(ClientProxyFactory.create(item)),
}));
const clients = (clientsOptions || []).map(item => {
return {
provide: item.name,
useFactory: () =>
this.assignOnAppShutdownHook(ClientProxyFactory.create(item)),
};
});
return {
module: ClientsModule,
global: !Array.isArray(options) && options.isGlobal,
Expand Down

0 comments on commit 31a0b18

Please sign in to comment.