Comments (4)
I think the best way to handle this is to adapt the server.js in y-websockets-server. Just copy it to your project, and adapt the way Yjs instances are created (line 35):
function getInstanceOfY (room) {
if (global.yInstances[room] == null) {
// create Yjs instance
var yPromise = Y({
db: {
name: options.db,
dir: 'y-leveldb-databases',
namespace: room
},
connector: {
name: 'websockets-server',
room: room,
io: io,
debug: !!options.debug
},
share: {
map: 'Map'
}
})
// get data from database (assuming it returns a promise)
var dbRequest = FeaszePerformsDBRequest(room, ..)
// wait for both promises to resolve
global.yInstances[room] = Promise.all([yPromise, dbRequest]).then(function ([y, dbContent]) {
// populate y with db content, e.g.
y.share.map.set('content', dbContent)
// When everything is ready, resolve the `global.yInstances[room]` promise (returning y)
// New users join this room only *after* this promise is resolved
return Promise.resolve(y)
})
}
return global.yInstances[room]
}
(+1 for issue quality)
from yjs.
I hope I was able to help. You can comment here if you want me to re-open this issue
from yjs.
Yes sorry for not letting you know. It works perfectly! Thanks for the help.
from yjs.
Great!
from yjs.
Related Issues (20)
- Y.Type is always AbstractType after `applyUpdate` HOT 2
- Error("Length exceeded!") should not be a module variable HOT 1
- `decodeStateVector` returns clock => client mapping instead of the opposite HOT 2
- Yjs backend validation with yjs-server in Fastify app
- Inconsistant output when updating same key in quick-start example HOT 1
- Allow to overwrite the clientID generation function in a YDoc HOT 3
- Fix links to docs
- README should mention "updateV2" event
- Add the topic #local-first be added to yjs repository
- How do I use persistence in y-websocket, such as leveldb or mongodb?
- Move redux binding to yjs org?
- Diff two versions of Y.Array/Y.Map
- Is it possible to read uintarray update data? HOT 1
- Misordered updates result in temporarily missing Y.Map keys HOT 5
- Merge transactions in undo manager HOT 7
- Mistake in documentation? Property 'set' does not exist on type 'YArray<unknown>'
- Logo as SVG? HOT 4
- RangeError Invalid typed array length: 110 & TypeError: contentRefs[(info & binary.BITS5)] is not a function HOT 2
- Support for TypeScript NodeNext HOT 4
- Inconsistent Y.XmlText.format behavior HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from yjs.