You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For large projects that use yjs, it is very likely that multiple documents will be shared and used at the same time on the front-end, and documents will be loaded or destroyed dynamically. Although hocuspocus has provided a front-end library @hocuspocus/provider, this library only supports a single document for a single WebSocket connection. Although we can implement multiple document sharing and multiple WebSocket connections by ourselves, @hocuspocus/server has a ready-made implementation, and its pattern can be moved to the front-end for use.
(PS: I tried using @hocuspocus/server on the front-end, but then quickly realized that @hocuspocus/server uses a lot of Node.js APIs, so actually it cannot be used on the front-end.)
To use @hocuspocus/server on the front-end, in addition to removing the dependence on the Node.js APIs, you only need to create two Extensions, which are used to connect the browser's IndexedDb and the backend's WebSocket, and then use openDirectConnection to get the document instance.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
For large projects that use yjs, it is very likely that multiple documents will be shared and used at the same time on the front-end, and documents will be loaded or destroyed dynamically. Although hocuspocus has provided a front-end library
@hocuspocus/provider
, this library only supports a single document for a single WebSocket connection. Although we can implement multiple document sharing and multiple WebSocket connections by ourselves,@hocuspocus/server
has a ready-made implementation, and its pattern can be moved to the front-end for use.(PS: I tried using
@hocuspocus/server
on the front-end, but then quickly realized that@hocuspocus/server
uses a lot of Node.js APIs, so actually it cannot be used on the front-end.)To use
@hocuspocus/server
on the front-end, in addition to removing the dependence on the Node.js APIs, you only need to create two Extensions, which are used to connect the browser's IndexedDb and the backend's WebSocket, and then useopenDirectConnection
to get the document instance.Beta Was this translation helpful? Give feedback.
All reactions