@@ -8,12 +8,33 @@ import { isEqual } from 'lodash';
8
8
9
9
import { CoreService , WorkspaceAttribute } from '../../types' ;
10
10
11
- type WorkspaceObject = WorkspaceAttribute & { libraryReadonly ?: boolean } ;
11
+ type WorkspaceObject = WorkspaceAttribute & { readonly ?: boolean } ;
12
+
12
13
interface WorkspaceObservables {
14
+ /**
15
+ * Indicates the current activated workspace id, the value should be changed every time
16
+ * when switching to a different workspace
17
+ */
13
18
currentWorkspaceId$ : BehaviorSubject < string > ;
19
+
20
+ /**
21
+ * The workspace that is derived from `currentWorkspaceId` and `workspaceList`, if
22
+ * `currentWorkspaceId` cannot be found from `workspaceList`, it will return an error
23
+ *
24
+ * This value MUST NOT set manually from outside of WorkspacesService
25
+ */
14
26
currentWorkspace$ : BehaviorSubject < WorkspaceObject | null > ;
27
+
28
+ /**
29
+ * The list of available workspaces. This workspace list should be set by whoever
30
+ * the workspace functionalities
31
+ */
15
32
workspaceList$ : BehaviorSubject < WorkspaceObject [ ] > ;
16
- workspaceEnabled$ : BehaviorSubject < boolean > ;
33
+
34
+ /**
35
+ * This is a flag which indicates the WorkspacesService module is initialized and ready
36
+ * for consuming by others. For example, the `workspaceList` has been set, etc
37
+ */
17
38
initialized$ : BehaviorSubject < boolean > ;
18
39
}
19
40
@@ -29,7 +50,6 @@ export class WorkspacesService implements CoreService<WorkspacesSetup, Workspace
29
50
private workspaceList$ = new BehaviorSubject < WorkspaceAttribute [ ] > ( [ ] ) ;
30
51
private currentWorkspace$ = new BehaviorSubject < WorkspaceAttribute | null > ( null ) ;
31
52
private initialized$ = new BehaviorSubject < boolean > ( false ) ;
32
- private workspaceEnabled$ = new BehaviorSubject < boolean > ( false ) ;
33
53
34
54
constructor ( ) {
35
55
combineLatest ( [ this . initialized$ , this . workspaceList$ , this . currentWorkspaceId$ ] ) . subscribe (
@@ -66,7 +86,6 @@ export class WorkspacesService implements CoreService<WorkspacesSetup, Workspace
66
86
currentWorkspace$ : this . currentWorkspace$ ,
67
87
workspaceList$ : this . workspaceList$ ,
68
88
initialized$ : this . initialized$ ,
69
- workspaceEnabled$ : this . workspaceEnabled$ ,
70
89
} ;
71
90
}
72
91
@@ -76,15 +95,13 @@ export class WorkspacesService implements CoreService<WorkspacesSetup, Workspace
76
95
currentWorkspace$ : this . currentWorkspace$ ,
77
96
workspaceList$ : this . workspaceList$ ,
78
97
initialized$ : this . initialized$ ,
79
- workspaceEnabled$ : this . workspaceEnabled$ ,
80
98
} ;
81
99
}
82
100
83
101
public async stop ( ) {
84
102
this . currentWorkspace$ . unsubscribe ( ) ;
85
103
this . currentWorkspaceId$ . unsubscribe ( ) ;
86
104
this . workspaceList$ . unsubscribe ( ) ;
87
- this . workspaceEnabled$ . unsubscribe ( ) ;
88
105
this . initialized$ . unsubscribe ( ) ;
89
106
}
90
107
}
0 commit comments