noflo:动态组件加载-组件[name]与基础[path]不可用
noflo: Dynamic component loading - Component [name] not available with base [path]
我得到错误:
Component [name] not available with base [path]
当尝试动态地将组件附加到网络的ComponentLoader实例时。
var components = []; // This is populated with noflo.Component instances at runtime.
var graph = {
properties: { name: 'Test components' },
processes: {
log: { component: 'log' },
split: { component: 'split' }
},
connections: [
{
data: 'John Doe',
tgt: { process: 'split', port: 'in' }
},
{
src: { process: 'split', port: 'left' },
tgt: { process: 'log', port: 'in' }
},
{
src: { process: 'split', port: 'right' },
tgt: { process: 'log', port: 'in' }
}
]
};
noflo.graph.loadJSON(graph, function(g) {
noflo.createNetwork(g, function(n) {
var getComponent = function(c) {
return c;
}
for (var i = 0; i < components.length; i++) {
var c = components[i];
n.loader.components[c.key] = {};
n.loader.components[c.key].getComponent = getComponent.bind(null, c);
};
});
});
我还尝试将组件直接分配给加载器中组件集合的属性:
n.loader.components[c.key] = c;
您可以使用NoFlo ComponentLoader的registerComponent
方法。诀窍是通过传递true
作为第三个参数以延迟模式启动NoFlo网络。这样它就不会立即开始执行,你可以先将你的组件注册到它。
// Create NoFlo network in delayed mode (see the third param in the end)
noflo.createNetwork(g, function(n) {
// Register the custom components
components.forEach (function (component) {
n.loader.registerComponent('myproject', component.key, {
getComponent: function () { return component; }
});
});
// Once the components have been registered we can wire up and start it
n.connect(function () {
n.start();
});
}, true);
另一个选择是在项目中注册一个自定义ComponentLoader。这样你在启动网络时就不需要做任何特别的事情了。
请参见浏览器上的noflo-polymer (manifest,自定义加载器)或Node.js上的MicroFlo (manifest,自定义加载器)。
自NoFlo 0.5.1开始支持自定义组件加载器
相关文章:
- 正在使用$location.path(.)路由ng视图
- AngularJS单选筛选不适用于Name、Description和Field4复选框值
- 未捕获的类型错误:无法读取属性'name'即使它存在,也无法定义
- gulp Iconify任务抛出错误TypeError:Path必须是字符串.收到false
- 正在检测导航到<a name=“;最新主题”></a>
- 骨干's Router.execute(callback,args,name)方法获取未定义的名称
- JavaScript,JQuery.需要帮助才能获得'name'从我的JSON中删除
- 从 Javascript 中设置 ng-model name
- jquery使用name from变量按类选择元素
- paper.js animation along a path
- 猫鼬——如何找到物体所在的场&;name”;不包含数字
- 如何让firefox使用style['attribute name']=设置样式属性
- Javascript,var name=1,“;类型名称“;给出“;字符串”;
- 无法使用 $('input[name=“rate”]').focus() 聚焦文本框;方法
- JS数组称为“;name”;行为怪异
- Form.target=window.opener.name不起作用
- Animating text along an circular path with svg & javascr
- SCRIPT5007:属性onclick=;JavaScript:functionName('name'
- noflo:动态组件加载-组件[name]与基础[path]不可用
- 什么是jquery正则表达式来匹配这个字符串“http://path/to/file/file-name-123x123