Fix PlatformSettingsHandler always returning true due to returning a Promise (#8954)

* Fix PlatformSettingsHandler always returning true due to returning a Promise

* Improve typescript
This commit is contained in:
Michael Telatynski 2022-06-30 15:48:21 +01:00 committed by GitHub
parent c3f26d619e
commit 424d33d4b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 72 additions and 8 deletions

View file

@ -16,6 +16,9 @@ limitations under the License.
*/
import BasePlatform from "./BasePlatform";
import defaultDispatcher from "./dispatcher/dispatcher";
import { Action } from "./dispatcher/actions";
import { PlatformSetPayload } from "./dispatcher/payloads/PlatformSetPayload";
/*
* Holds the current instance of the `Platform` to use across the codebase.
@ -29,23 +32,26 @@ import BasePlatform from "./BasePlatform";
* object.
*/
export class PlatformPeg {
platform: BasePlatform = null;
private platform: BasePlatform = null;
/**
* Returns the current Platform object for the application.
* This should be an instance of a class extending BasePlatform.
*/
get() {
public get() {
return this.platform;
}
/**
* Sets the current platform handler object to use for the
* application.
* This should be an instance of a class extending BasePlatform.
* Sets the current platform handler object to use for the application.
* @param {BasePlatform} platform an instance of a class extending BasePlatform.
*/
set(plaf: BasePlatform) {
this.platform = plaf;
public set(platform: BasePlatform) {
this.platform = platform;
defaultDispatcher.dispatch<PlatformSetPayload>({
action: Action.PlatformSet,
platform,
});
}
}