在https://github.com/holochain/holochat-rust中,如何获得ui/holoclient.js和ui/holoclient.map文件?
另外,是否有任何关于我错过的官方文档,这是否仍然是获得UI与holochain容器对话的方式?
发布于 2019-01-22 20:43:40
ui/holoclient.js是一个微型图书馆,它使与运行中的Holochain应用程序实例更容易交谈。当前通过本地WebSocket连接将GUI连接到实例的方法是类似于JSON的进程。它是一个很好的包装器,可以让zome函数调用感觉像本地的、浏览器中的函数调用。文档目前很轻,但是不需要花太多时间就能弄清楚它应该如何使用示例。简而言之:
const url = 'ws://localhost:3000/'
window.holoclient.connect(url).then(({call, close}) => {
document.getElementById('form').addEventListener('submit', e => {
e.preventDefault()
// First, get a list of locally running Holochain instances...
call('info/instances')().then(info => {
// Now that we have instance info, we can make zome calls into any of them
// by referring to them by DNA hash (and agent ID) as specified in our
// container config.
// Search for the instance we're looking for, given known DNA and agent
// hashes.
const matchingInstances = Object.entries(info)
.find(([id, value]) => value.dna === 'blog_dna_hash' && value.agent === 'my_agent_hash')
const instance = getInstance(info, 'the_dna_hash', 'the_agent_hash')
const content = document.querySelector('#message').value
// Make another zome call now
call(instance, 'blog', 'main', 'create_post')({
content: content
})
})
})
})它是用TypeScript编写的,这意味着ui/holoclient.map是一个“源图”文件,它将编译后的JavaScript文件中的行号映射到原始TypeScript源代码中的行号。在调试JS时,Chrome和Firefox都会查找和使用这些源地图。
https://stackoverflow.com/questions/53722469
复制相似问题