@@ -17,7 +17,7 @@ export abstract class YDocument<T extends DocumentChange>
17
17
{
18
18
constructor ( options ?: YDocument . IOptions ) {
19
19
this . _ydoc = options ?. ydoc ?? new Y . Doc ( ) ;
20
- this . forkId = options ?. forkId ?? 'root ' ;
20
+ this . roomId = options ?. roomId ?? '' ;
21
21
22
22
this . _ystate = this . _ydoc . getMap ( 'state' ) ;
23
23
@@ -29,8 +29,6 @@ export abstract class YDocument<T extends DocumentChange>
29
29
this . _awareness = new Awareness ( this . _ydoc ) ;
30
30
31
31
this . _ystate . observe ( this . onStateChanged ) ;
32
-
33
- this . _providers = { } ;
34
32
}
35
33
36
34
/**
@@ -42,22 +40,15 @@ export abstract class YDocument<T extends DocumentChange>
42
40
this . ystate . set ( `fork_${ forkId } ` , 'new' ) ;
43
41
}
44
42
45
- getProvider ( providerId : string , sharedModel ?: ISharedDocument ) : IDocumentProvider {
46
- if ( ! ( providerId in this . _providers ) ) {
47
- if ( providerId === 'root' ) {
48
- throw new Error ( 'Cannot get a new provider for root document' ) ;
49
- }
50
- if ( sharedModel === undefined ) {
51
- throw new Error ( 'New provider needs a shared document' ) ;
52
- }
53
- const root_provider = this . _providers [ 'root' ] ;
54
- this . _providers [ providerId ] = root_provider . connectFork ( providerId , sharedModel ! ) ;
43
+ get provider ( ) : IDocumentProvider {
44
+ if ( this . _provider === undefined ) {
45
+ throw new Error ( 'YDocument has no provider' ) ;
55
46
}
56
- return this . _providers [ providerId ] ;
47
+ return this . _provider ;
57
48
}
58
49
59
- setProvider ( providerId : string , provider : IDocumentProvider ) {
60
- this . _providers [ providerId ] = provider ;
50
+ set provider ( provider : IDocumentProvider ) {
51
+ this . _provider = provider ;
61
52
}
62
53
63
54
/**
@@ -257,8 +248,8 @@ export abstract class YDocument<T extends DocumentChange>
257
248
private _awareness : Awareness ;
258
249
private _isDisposed = false ;
259
250
private _disposed = new Signal < this, void > ( this ) ;
260
- private _providers : { [ key : string ] : IDocumentProvider } ;
261
- public forkId : string ;
251
+ private _provider : IDocumentProvider ;
252
+ public roomId : string ;
262
253
}
263
254
264
255
/**
@@ -275,8 +266,8 @@ export namespace YDocument {
275
266
ydoc ?: Y . Doc ;
276
267
277
268
/**
278
- * The document fork ID, defaults to 'root '.
269
+ * The document room ID, defaults to ''.
279
270
*/
280
- forkId ?: string ;
271
+ roomId ?: string ;
281
272
}
282
273
}
0 commit comments