我已经设法通过DDP连接了两个应用程序,但是我对如何从原始服务器发布数据有点不确定。
以下是我对客户的尝试:
Template.Dashboard.onCreated(function() {
Meteor.remoteConnection = DDP.connect('http://localhost:3030');
this.subscribe('templatePublication', {
connection: Meteor.remoteConnection
});
});
它应该是在源服务器上调用一个发布。它没有抛出任何错误,但同时也没有生成任何文档,因为发布是一个简单的Collection.find({});
只是好奇我是不是错过了什么…
发布于 2018-03-10 17:42:47
我解决了这个问题!好像我把事情弄得太复杂了。看起来你必须这样做(这都是在客户端上):
import { DDP } from 'meteor/ddp-client'
var remote = DDP.connect('http://localhost:3030/');
Templates = new Meteor.Collection('templates', remote);
Template.Dashboard.onCreated(function(){
remote.subscribe('templatePublication');
});
Template.Dashboard.helpers({
listTemplates: ()=>{
return Templates.find();
}
});
https://stackoverflow.com/questions/49211775
复制相似问题