@@ -10,11 +10,31 @@ import { CoreService, WorkspaceAttribute } from '../../types';
10
10
11
11
type WorkspaceObject = WorkspaceAttribute & { readonly ?: boolean } ;
12
12
13
- export interface WorkspaceObservables {
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
+ */
14
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
+ */
15
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
+ */
16
32
workspaceList$ : BehaviorSubject < WorkspaceObject [ ] > ;
17
- 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
+ */
18
38
initialized$ : BehaviorSubject < boolean > ;
19
39
}
20
40
@@ -30,7 +50,6 @@ export class WorkspacesService implements CoreService<WorkspacesSetup, Workspace
30
50
private workspaceList$ = new BehaviorSubject < WorkspaceObject [ ] > ( [ ] ) ;
31
51
private currentWorkspace$ = new BehaviorSubject < WorkspaceObject | null > ( null ) ;
32
52
private initialized$ = new BehaviorSubject < boolean > ( false ) ;
33
- private workspaceEnabled$ = new BehaviorSubject < boolean > ( false ) ;
34
53
35
54
constructor ( ) {
36
55
combineLatest ( [ this . initialized$ , this . workspaceList$ , this . currentWorkspaceId$ ] ) . subscribe (
@@ -67,7 +86,6 @@ export class WorkspacesService implements CoreService<WorkspacesSetup, Workspace
67
86
currentWorkspace$ : this . currentWorkspace$ ,
68
87
workspaceList$ : this . workspaceList$ ,
69
88
initialized$ : this . initialized$ ,
70
- workspaceEnabled$ : this . workspaceEnabled$ ,
71
89
} ;
72
90
}
73
91
@@ -77,15 +95,13 @@ export class WorkspacesService implements CoreService<WorkspacesSetup, Workspace
77
95
currentWorkspace$ : this . currentWorkspace$ ,
78
96
workspaceList$ : this . workspaceList$ ,
79
97
initialized$ : this . initialized$ ,
80
- workspaceEnabled$ : this . workspaceEnabled$ ,
81
98
} ;
82
99
}
83
100
84
101
public async stop ( ) {
85
102
this . currentWorkspace$ . unsubscribe ( ) ;
86
103
this . currentWorkspaceId$ . unsubscribe ( ) ;
87
104
this . workspaceList$ . unsubscribe ( ) ;
88
- this . workspaceEnabled$ . unsubscribe ( ) ;
89
105
this . initialized$ . unsubscribe ( ) ;
90
106
}
91
107
}
0 commit comments