File tree Expand file tree Collapse file tree 2 files changed +20
-3
lines changed
Expand file tree Collapse file tree 2 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -32,10 +32,16 @@ export class DataProvider<T extends IBaseRestApiResponse> implements IDataProvid
3232 private scheduleUpdate : ( ) => void ;
3333 private cache : IRestApiResponse < T > ;
3434
35- constructor ( requestFactory : IRequestFactory , responseHandler : IResponseHandler < T > , listenTo : IListenTo ) {
35+ constructor (
36+ requestFactory : IRequestFactory ,
37+ responseHandler : IResponseHandler < T > ,
38+ listenTo : IListenTo ,
39+ updateTimeout ?: number ,
40+ ) {
3641 this . requestFactory = requestFactory ;
3742 this . responseHandler = responseHandler ;
3843 this . listenTo = listenTo || { } ;
44+ this . updateTimeout = updateTimeout ?? this . updateTimeout ;
3945 this . scheduleUpdate = debounce ( ( ) => this . fetch ( ) , this . updateTimeout ) ;
4046
4147 // init
Original file line number Diff line number Diff line change @@ -11,6 +11,8 @@ class DataStore {
1111 public contentProfiles : OrderedMap < IContentProfile [ '_id' ] , IContentProfile > ;
1212 public users : OrderedMap < IUser [ '_id' ] , IUser > ;
1313
14+ private initializePromise : Promise < any > ;
15+
1416 constructor ( ) {
1517 this . contentProfiles = OrderedMap ( ) ;
1618 }
@@ -81,13 +83,22 @@ class DataStore {
8183
8284 resolveOnce ( ) ;
8385 } ,
84- { 'users' : true } ,
86+ { 'users' : {
87+ create : true ,
88+ delete : true ,
89+ update : [ 'display_name' ] ,
90+ } } ,
91+ 2000 ,
8592 ) ;
8693 } ) ;
8794 }
8895
8996 initialize ( ) {
90- return Promise . all ( [ this . loadContentProfiles ( ) , this . loadUsers ( ) ] ) ;
97+ if ( this . initializePromise == null ) {
98+ this . initializePromise = Promise . all ( [ this . loadContentProfiles ( ) , this . loadUsers ( ) ] ) ;
99+ }
100+
101+ return this . initializePromise ;
91102 }
92103}
93104
You can’t perform that action at this time.
0 commit comments