requirejs locate plugin使用RequireJS插件实现服务定位器模式
RequireJS定位插件通过使用RequireJS插件实现服务定位器模式。这允许请求服务的语义与请求模块融合。在某种程度上,它是依赖项注入,其中依赖项通过代码即时注入,而不是通过配置声明。
用法:注册服务'registry'
是一个保留的服务名称,它返回服务注册表。它有方法.register(name, service)
和.unregister(name, service)
。
// Locate the registry
require([\"locate!registry\", \"oauth\"], function (registry, oauth) {
// Add some services to the registry
// The one and only authentication module registr
});
下载地址
用户评论