Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
this._syncing = true
this.emit(`syncing-${communityId}`)
y.connector.whenSynced(() => {
setTimeout(() => {
this._syncing = false
this.emit(`synced-${communityId}`)
}, 1000)
})
}
})
}
const options = yConfig(node, communityId)
options.connector = { ...options.connector, onSubscribed }
const y = new Y(`thicket:${communityId}`, options, persistence)
y.share.publications = y.define('publications', Y.Array)
y.share.metadata = y.define('map', Y.Map)
y.share.publicationsMetadata = y.define('map', Y.Map)
y.share.nicknames = y.define('map', Y.Map)
// updates to the community metadata (eg change community title)
y.share.metadata.observe(({ value, type }) => {
if (value && type !== 'delete') {
if (!this._syncing) {
this.emit(`update-${communityId}`, value)
}
}
})
// updates to the publications (eg new publication)
y.share.publications.observe(async ({ type, values }) => {
if (!this._syncing) {
this.emit(`update-${communityId}-publications`, await this.publicationsGetAll(communityId))
yclient(Y);
yindexeddb(Y);
const persistence = new Y.IndexedDB();
let y = new Y(
networkName, {
connector: {
name: 'websockets-client',
url: 'https://my-websockets-server.herokuapp.com/'
}
},
persistence);
let chatprotocol = y.define('chat', Y.Array);
let commitProtocol = y.define('commits', Y.Array);
let configProtocol = y.define('config', Y.Map);
dispatchCommitProtocol(dispatch, commitProtocol);
dispatchConfigProtocol(dispatch, configProtocol);
configProtocol.observe(event => {
dispatchConfigEvent(dispatch, event.target);
});
commitProtocol.observe(event => {
let elements: any[] = Array.from(event.addedElements);
let commits = elements.reduce(
(r: any[], e) => {
r.push(...e._content);
return r;
},
cb: (protocol: any) => void) => {
yclient(Y);
yindexeddb(Y);
const persistence = new Y.IndexedDB();
let y = new Y(
networkName, {
connector: {
name: 'websockets-client',
url: 'https://my-websockets-server.herokuapp.com/'
}
},
persistence);
let chatprotocol = y.define('chat', Y.Array);
let commitProtocol = y.define('commits', Y.Array);
let configProtocol = y.define('config', Y.Map);
dispatchCommitProtocol(dispatch, commitProtocol);
dispatchConfigProtocol(dispatch, configProtocol);
configProtocol.observe(event => {
dispatchConfigEvent(dispatch, event.target);
});
commitProtocol.observe(event => {
let elements: any[] = Array.from(event.addedElements);
let commits = elements.reduce(
(r: any[], e) => {
r.push(...e._content);
return r;