@@ -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
/**
@@ -225,8 +216,8 @@ export abstract class YDocument<T extends DocumentChange>
225
216
private _awareness : Awareness ;
226
217
private _isDisposed = false ;
227
218
private _disposed = new Signal < this, void > ( this ) ;
228
- private _providers : { [ key : string ] : IDocumentProvider } ;
229
- public forkId : string ;
219
+ private _provider : IDocumentProvider ;
220
+ public roomId : string ;
230
221
}
231
222
232
223
/**
@@ -243,8 +234,8 @@ export namespace YDocument {
243
234
ydoc ?: Y . Doc ;
244
235
245
236
/**
246
- * The document fork ID, defaults to 'root '.
237
+ * The document room ID, defaults to ''.
247
238
*/
248
- forkId ?: string ;
239
+ roomId ?: string ;
249
240
}
250
241
}
0 commit comments