Skip to content

Instantly share code, notes, and snippets.

@jachiang
Created December 1, 2017 14:25
Show Gist options
  • Save jachiang/d38ed1d00a38288557f902ee357e9955 to your computer and use it in GitHub Desktop.
Save jachiang/d38ed1d00a38288557f902ee357e9955 to your computer and use it in GitHub Desktop.
yjsTest > Y promise doesn't return anything?
// you need to create and inject a IPFS object
const IPFS = require('ipfs')
const Y = require('yjs')
require('y-ipfs-connector')(Y)
// other Yjs deps:
require('y-memory')(Y)
require('y-array')(Y)
require('y-text')(Y)
// create IPFS node
const ipfsNode = new IPFS({
EXPERIMENTAL: {
pubsub: true // need this to work
}
})
Y({
db: {
name: 'memory'
},
connector: {
name: 'ipfs', // use the IPFS connector
ipfs: ipfsNode, // inject the IPFS object
room: 'Textarea-example-dev'
},
sourceDir: '/node_modules', // location of the y-* modules
share: {
textarea: 'Text' // y.share.textarea is of type Y.Text
}
}).then(function(y) { //ok so they use promises ...
// bind the textarea to a shared text element
return y;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment