File tree 1 file changed +11
-5
lines changed
packages/composable-controller/src 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -166,6 +166,12 @@ export class ComposableController extends BaseController<
166
166
* @param controller - Controller instance to update
167
167
*/
168
168
#updateChildController( controller : ControllerInstance ) : void {
169
+ if ( ! isBaseController ( controller ) && ! isBaseControllerV1 ( controller ) ) {
170
+ throw new Error (
171
+ 'Invalid controller: controller must extend from BaseController or BaseControllerV1' ,
172
+ ) ;
173
+ }
174
+
169
175
const { name } = controller ;
170
176
if ( isBaseControllerV1 ( controller ) ) {
171
177
controller . subscribe ( ( childState ) => {
@@ -174,7 +180,11 @@ export class ComposableController extends BaseController<
174
180
[ name ] : childState ,
175
181
} ) ) ;
176
182
} ) ;
177
- } else if ( isBaseController ( controller ) ) {
183
+ }
184
+ if (
185
+ ( isBaseControllerV1 ( controller ) && 'messagingSystem' in controller ) ||
186
+ isBaseController ( controller )
187
+ ) {
178
188
this . messagingSystem . subscribe (
179
189
`${ name } :stateChange` ,
180
190
( childState : StateConstraint ) => {
@@ -184,10 +194,6 @@ export class ComposableController extends BaseController<
184
194
} ) ) ;
185
195
} ,
186
196
) ;
187
- } else {
188
- throw new Error (
189
- 'Invalid controller: controller must extend from BaseController or BaseControllerV1' ,
190
- ) ;
191
197
}
192
198
}
193
199
}
You can’t perform that action at this time.
0 commit comments