-
-
Notifications
You must be signed in to change notification settings - Fork 186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changed PollingController to be a mixin so it can be used with both V1 and V2 controllers #1736
Conversation
…and V2 controllers
c162a8b
to
82255b8
Compare
} | ||
setIntervalLength(length: number) { | ||
this.#intervalLength = length; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does intervalLength need to be private if we're just exposing it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could make it protected
so that the extending class could decide to expose it or not. I doubt we need this to be configurable at runtime very often, if ever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a way to do this (make it protected
), just not if I have an abstract
class where the class has to be named.
} catch (error) { | ||
console.error(error); | ||
|
||
onPollingComplete( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit]
onPollingComplete( | |
setOnPollingComplete( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems a bit more conventional as-is IMO. Event listeners are usually on____
. Or add___Listener
messenger, | ||
metadata, | ||
}); | ||
#intervalLength = 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nit] Wondering if we ought remove a default and throw if never set?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! I can re-review after some of these suggestions are resolved
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Integrates recently introduced [`PollingController` mixin](#1736) with `GasFeeController`. Leaves old polling pattern in pace for now so as to not force a ton of breaking changes for mobile, but with intention to activate new pattern in both clients ASAP. Addresses: MetaMask/MetaMask-planning#1314
…1 and V2 controllers (#1736) ## Explanation - Currently the PollingController extends from BaseControllerV2 but we need to use it for both V1 and V2 controllers. - This PR uses typescript [mixins](https://www.typescriptlang.org/docs/handbook/mixins.html) to achieve a faux-multiple inheritance which TypeScript has support for. The pattern allows you to create a class which is a merge of many classes. I've added a V1 and a V2 version of the PollingController that can be used almost the same way as the original `PollingController`. --------- Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Integrates recently introduced [`PollingController` mixin](#1736) with `GasFeeController`. Leaves old polling pattern in pace for now so as to not force a ton of breaking changes for mobile, but with intention to activate new pattern in both clients ASAP. Addresses: MetaMask/MetaMask-planning#1314
…1 and V2 controllers (#1736) ## Explanation - Currently the PollingController extends from BaseControllerV2 but we need to use it for both V1 and V2 controllers. - This PR uses typescript [mixins](https://www.typescriptlang.org/docs/handbook/mixins.html) to achieve a faux-multiple inheritance which TypeScript has support for. The pattern allows you to create a class which is a merge of many classes. I've added a V1 and a V2 version of the PollingController that can be used almost the same way as the original `PollingController`. --------- Co-authored-by: Mark Stacey <markjstacey@gmail.com>
Integrates recently introduced [`PollingController` mixin](#1736) with `GasFeeController`. Leaves old polling pattern in pace for now so as to not force a ton of breaking changes for mobile, but with intention to activate new pattern in both clients ASAP. Addresses: MetaMask/MetaMask-planning#1314
Explanation
allows you to create a class which is a merge of many classes. I've added a V1 and a V2 version of the PollingController that can be used almost the same way as the original
PollingController
.