Skip to content

Commit

Permalink
Restore ComposableController compatibility between different BaseCont…
Browse files Browse the repository at this point in the history
…rollers

When adding support for BaseControllerV2 to the ComposableController
in #447, we accidentally removed support for using two different
versions of the BaseController in the same ComposableController. This
is because we used the `instanceof` operator to check whether a
controller was extended from BaseController.

The `instanceof` check has been replaced by a check for the `subscribe`
function. It seems unlikely that a BaseControllerV2 controller will
ever have a `subscribe` function because the controller messenger
will be used for all events.
  • Loading branch information
Gudahtt committed Apr 30, 2021
1 parent 8ddae28 commit b6e67d1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/ComposableController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ export class ComposableController extends BaseController<never, any> {
this.messagingSystem = messenger;
this.controllers.forEach((controller) => {
const { name } = controller;
if (controller instanceof BaseController) {
controller.subscribe((state) => {
if ((controller as BaseController<any, any>).subscribe !== undefined) {
(controller as BaseController<any, any>).subscribe((state) => {
this.update({ [name]: state });
});
} else if (this.messagingSystem) {
Expand Down

0 comments on commit b6e67d1

Please sign in to comment.