simple-boot-core
Advanced tools
Comparing version 1.0.30 to 1.0.31
{ | ||
"name": "simple-boot-core", | ||
"version": "1.0.30", | ||
"version": "1.0.31", | ||
"main": "SimpleApplication.js", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -280,2 +280,3 @@ SIMPLE-BOOT-CORE | ||
class AppRouter { | ||
@Route({path:'/user'}) | ||
@@ -285,2 +286,3 @@ user1() { | ||
} | ||
@Route({path:'/user'}) | ||
@@ -290,2 +292,7 @@ user2() { | ||
} | ||
@Route({path:'/user-props'}) | ||
user2(props: string) { | ||
console.log('user propss', props) | ||
} | ||
} | ||
@@ -297,4 +304,10 @@ | ||
it.executeModuleProperty(key); | ||
}) | ||
}); | ||
}) | ||
new SimpleApplication(AppRouter, option).run().routing('/user-props').then(it => { | ||
// direct call | ||
let propertyKey = it.propertyKeys?.[0]; | ||
let moduleInstance = routerModule.getModuleInstance<(props: string) => void>(propertyKey); | ||
moduleInstance('propData'); | ||
}) | ||
// output 💥 | ||
@@ -301,0 +314,0 @@ // user say1~ |
@@ -17,3 +17,3 @@ import { ConstructorType } from '../types/Types'; | ||
constructor(simstanceManager: SimstanceManager, router?: R | undefined, module?: ConstructorType<M> | undefined, routerChains?: R[]); | ||
getModuleInstance<T = M>(): T | undefined; | ||
getModuleInstance<T = M>(propertyKey?: string | symbol, instanceBind?: boolean | any): T | undefined; | ||
executeModuleProperty(propertyKey: string | symbol, ...param: any[]): any; | ||
@@ -20,0 +20,0 @@ get lastRouteChain(): R; |
@@ -13,4 +13,18 @@ "use strict"; | ||
} | ||
RouterModule.prototype.getModuleInstance = function () { | ||
return this.simstanceManager.getOrNewSim(this.module); | ||
RouterModule.prototype.getModuleInstance = function (propertyKey, instanceBind) { | ||
if (instanceBind === void 0) { instanceBind = true; } | ||
var instance = this.simstanceManager.getOrNewSim(this.module); | ||
if (propertyKey && this.propertyKeys && this.propertyKeys.includes(propertyKey)) { | ||
var instanceElement = instance[propertyKey]; | ||
if (instanceBind && typeof instanceBind === 'boolean') { | ||
instanceElement = instanceElement.bind(instance); | ||
} | ||
else if (instanceBind && typeof instanceBind === 'object') { | ||
instanceElement = instanceElement.bind(instanceBind); | ||
} | ||
return instanceElement; | ||
} | ||
else { | ||
return instance; | ||
} | ||
}; | ||
@@ -17,0 +31,0 @@ RouterModule.prototype.executeModuleProperty = function (propertyKey) { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
127127
2656
363