@@ -24,23 +24,31 @@ export interface PropertyRef extends ContribRef, CallbackRef, InputRef {
2424 property : string ;
2525}
2626
27- export function handleHostStoreChange ( ) {
27+ /**
28+ * This action is called once a host store change has been detected.
29+ * Note this will only create callback requests for callbacks whose input
30+ * value are affected by the change.
31+ *
32+ * @returns The array of callback requests made or `undefined`,
33+ * if no callback requests have been made.
34+ */
35+ export function handleHostStoreChange ( ) : CallbackRequest [ ] | undefined {
2836 const { extensions, configuration, contributionsRecord } = store . getState ( ) ;
2937 const { hostStore } = configuration ;
3038 if ( ! hostStore ) {
3139 // Exit if no host store configured.
3240 // Actually, we should not come here.
33- return ;
41+ return undefined ;
3442 }
3543 synchronizeThemeMode ( hostStore ) ;
3644 if ( extensions . length === 0 ) {
3745 // Exit if there are no extensions (yet)
38- return ;
46+ return undefined ;
3947 }
4048 const propertyRefs = getPropertyRefsForContribPoints ( contributionsRecord ) ;
4149 if ( ! propertyRefs || propertyRefs . length === 0 ) {
4250 // Exit if there are is nothing to be changed
43- return ;
51+ return undefined ;
4452 }
4553 const callbackRequests = getCallbackRequests (
4654 propertyRefs ,
@@ -52,9 +60,12 @@ export function handleHostStoreChange() {
5260 ( callbackRequest ) : callbackRequest is CallbackRequest =>
5361 callbackRequest !== undefined ,
5462 ) ;
55- if ( filteredCallbackRequests && filteredCallbackRequests . length > 0 ) {
56- invokeCallbacks ( filteredCallbackRequests ) ;
63+ if ( ! filteredCallbackRequests || ! filteredCallbackRequests . length ) {
64+ return undefined ;
5765 }
66+
67+ invokeCallbacks ( filteredCallbackRequests ) ;
68+ return filteredCallbackRequests ;
5869}
5970
6071// Exporting for testing only
0 commit comments