调用命名空间功能,我使用由彼得·苏当在Meteor Meetup Antwerp所示的结构设计流星包唯一的方法,从不同的包
我由有根据的功能,不同的命名空间的名称(USERAUTH,AppRoute)取得了成功我的模块。然而,我想拥有一个特定于应用程序的命名空间UP(UserPortal)并且具有像UP.UserAuth,UP.AppRoutes这样的命名空间。
我似乎无法调用UP.UserAuth中的函数来检查登录。
我上的应用程序包package.js看起来像这样
Package.describe({
name: 'up-app',
version: '0.0.1',
summary: 'User Portal Application',
});
var both=['server','client'];
var server ='server';
var client ='client';
Package.onUse(function(api) {
api.versionsFrom('1.0.3.2');
api.use('templating',client);
api.use('iron:[email protected]',both);
api.use('tracker',both);
api.use('underscore',both);
api.use('blaze',both);
api.use(['up-user-auth'],both);
api.addFiles(['lib/namespace.js','lib/routes.js'],both);
api.addFiles(['views/dashboard.html','views/loading.html'],client);
api.export('UP');
});
Package.onTest(function(api) {
api.use('tinytest');
api.use('up-app');
api.addFiles('tests/up-app-tests.js');
});
我打算用了,应用在单个封装内宣布我的所有应用程序的依赖关系。
我上的应用程序/ lib目录/ routes.js文件看起来像这样:
Router.configure({
layoutTemplate: 'upDashBoard',
loadingTemplate: 'upLoading'
});
Router.onBeforeAction(UP.UserAuth.loginRequired, {
except: ['login','install']
});
Router.route('/', {
name: 'home'
});
我上用户身份验证包有这个在其package.js
Package.describe({
name: 'up-user-auth',
version: '0.0.1',
// Brief, one-line summary of the package.
summary: 'User Authentication and Roles Management',
});
Package.onUse(function(api) {
var both = ['server', 'client'];
var server = 'server';
var client = 'client';
api.versionsFrom('1.0.3.2');
api.use([
'tracker',
'service-configuration',
'accounts-base',
'underscore',
'templating',
'blaze',
'session',
'sha',
]
,client);
api.use([
'tracker',
'service-configuration',
'accounts-password',
'accounts-base',
'underscore',]
,server);
api.use(['iron:[email protected]','copleykj:mesosphere'], both);
api.imply(['accounts-base','accounts-password'], both);
api.addFiles(['lib/namespace.js','lib/loginValidation.js','lib/loginMethods.js'],both);
api.export('UP', both);
});
Package.onTest(function(api) {
api.use('tinytest');
api.use('up-user-auth');
api.addFiles('tests/server/up-user-auth-tests.js');
});
我了/ LIB/namespace.js看起来是这样的:
UP={};
UP.UserAuth={
loginRequired: function() {
return console.log("loginControllers");
}
}
如果我删除了第二参考UP={};
然后我得到一个错误说 无法设置的不确定财产“USERAUTH”但是当我加入这一切我得到的是无法读取属性未定义
我在做什么错“loginRequired”?
导致循环依赖错误,因为上的应用程序使用向上用户身份验证是为了访问UP.UserAuth。 – Churchill 2015-04-01 10:11:16