Comparing version 1.0.0-alpha.17 to 1.0.0-alpha.18
@@ -271,9 +271,9 @@ /*! | ||
/** | ||
* This getter returns arguments, with which module will be mounted (indes.js, router.js will receive this set of arguments) | ||
* This mixin returns arguments, with which module will be mounted (index.js, router.js will receive this set of arguments) | ||
* @returns {Array} | ||
*/ | ||
getRouterMountingArguments() { | ||
let args = [Client.routes]; // default calling arguments (are passed into module router) | ||
mixinModuleMounterContextArguments(moduleRouterMiddleware) { | ||
let args = [moduleRouterMiddleware]; // default calling arguments (are passed into module router) | ||
if (this.canUseDb()) { // TODO: push db instance reference | ||
if (this.canUseDb()) { | ||
args.push(this.db.instance); | ||
@@ -280,0 +280,0 @@ } |
@@ -14,3 +14,3 @@ /*! | ||
// expects app's context as first argument, router instance, model register | ||
return function handlerMounter(handlerContext) { | ||
return function handlerMounter(handlerContext/*, router, addModel*/) { | ||
if (!handler) { | ||
@@ -21,4 +21,4 @@ handler = module.parent.require.call(this, handlerAbsPath); // do not pass context as argument | ||
if (handler instanceof Function) { | ||
if (handlerContext.getRouterMountingArguments instanceof Function) { // getRouterMountingArguments should return Array of arguments | ||
return handler.apply(handlerContext, handlerContext.getRouterMountingArguments()); | ||
if (handlerContext.mixinModuleMounterContextArguments instanceof Function) { // getRouterMountingArguments should return Array of arguments | ||
return handler.apply(handlerContext, handlerContext.mixinModuleMounterContextArguments(arguments[1]/*prepared router instance with middlewares and namespace /moduleName/ */)); | ||
} | ||
@@ -25,0 +25,0 @@ else { // otherwise it will be called with [Router, addModel] as for now. |
{ | ||
"name": "teo.js", | ||
"description": "Teo.JS is a next generation HMVC web framework, built using ECMAScript 2015 (ES6)", | ||
"version": "1.0.0-alpha.17", | ||
"version": "1.0.0-alpha.18", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Andrew Teologov", |
@@ -450,7 +450,7 @@ /*! | ||
it("Should return arguments for module mounter with db enabled", () => { | ||
it("Should return mixed arguments for module mounter with db instance", () => { | ||
canUseDbStub.returns(true); | ||
let args = app.getRouterMountingArguments(); | ||
let args = app.mixinModuleMounterContextArguments("my router"); | ||
@@ -460,3 +460,3 @@ assert.isArray(args, "Arguments array should be returned"); | ||
assert.equal(args[0], Client.routes, "Clients.routes API should be the first argument"); | ||
assert.equal(args[0], "my router", "Clients.routes API should be the first argument"); | ||
assert.equal(args[1], "test", "app.db.instance object should be the second argument"); | ||
@@ -466,7 +466,7 @@ | ||
it("Should return arguments for module mounter wihtout db enabled", () => { | ||
it("Should return arguments for module mounter without db enabled", () => { | ||
canUseDbStub.returns(false); | ||
let args = app.getRouterMountingArguments(); | ||
let args = app.mixinModuleMounterContextArguments("my router"); | ||
@@ -476,3 +476,3 @@ assert.isArray(args, "Arguments array should be returned"); | ||
assert.equal(args[0], Client.routes, "Clients.routes API should be the first argument"); | ||
assert.equal(args[0], "my router", "Clients.routes API should be the first argument"); | ||
@@ -479,0 +479,0 @@ }); |
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
199103