mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-05 12:56:42 +02:00
Migrate to EventBus
This commit is contained in:
@@ -20,7 +20,11 @@ type ScriptEvents = {
|
||||
deviceVibrationUpdated: {};
|
||||
|
||||
// GH pages
|
||||
listForcedNativeMkbUpdated: {};
|
||||
listForcedNativeMkbUpdated: {
|
||||
data: {
|
||||
data: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
type StreamEvents = {
|
||||
@@ -29,6 +33,8 @@ type StreamEvents = {
|
||||
statePlaying: { $video?: HTMLVideoElement };
|
||||
stateStopped: {};
|
||||
stateError: {};
|
||||
|
||||
dataChannelCreated: { dataChannel: RTCDataChannel };
|
||||
};
|
||||
|
||||
export class BxEventBus<TEvents extends Record<string, any>> {
|
||||
|
@@ -16,8 +16,6 @@ export namespace BxEvent {
|
||||
export const REMOTE_PLAY_READY = 'bx-remote-play-ready';
|
||||
export const REMOTE_PLAY_FAILED = 'bx-remote-play-failed';
|
||||
|
||||
export const DATA_CHANNEL_CREATED = 'bx-data-channel-created';
|
||||
|
||||
export const GAME_BAR_ACTION_ACTIVATED = 'bx-game-bar-action-activated';
|
||||
export const MICROPHONE_STATE_CHANGED = 'bx-microphone-state-changed';
|
||||
export const SPEAKER_STATE_CHANGED = 'bx-speaker-state-changed';
|
||||
|
@@ -53,7 +53,9 @@ export class GhPagesUtils {
|
||||
if (json.$schemaVersion === supportedSchema) {
|
||||
// Save to storage
|
||||
window.localStorage.setItem(key, JSON.stringify(json));
|
||||
BxEventBus.Script.emit('listForcedNativeMkbUpdated', {});
|
||||
BxEventBus.Script.emit('listForcedNativeMkbUpdated', {
|
||||
data: json,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
@@ -76,10 +76,7 @@ export function patchRtcPeerConnection() {
|
||||
// @ts-ignore
|
||||
const dataChannel = nativeCreateDataChannel.apply(this, arguments);
|
||||
|
||||
BxEvent.dispatch(window, BxEvent.DATA_CHANNEL_CREATED, {
|
||||
dataChannel: dataChannel,
|
||||
});
|
||||
|
||||
BxEventBus.Stream.emit('dataChannelCreated', { dataChannel });
|
||||
return dataChannel;
|
||||
}
|
||||
|
||||
|
@@ -432,8 +432,8 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
|
||||
if (!setting.unsupported) {
|
||||
(setting as any).multipleOptions = GhPagesUtils.getNativeMkbCustomList(true);
|
||||
|
||||
BxEventBus.Script.on('listForcedNativeMkbUpdated', () => {
|
||||
(setting as any).multipleOptions = GhPagesUtils.getNativeMkbCustomList();
|
||||
BxEventBus.Script.on('listForcedNativeMkbUpdated', payload => {
|
||||
(setting as any).multipleOptions = payload.data.data;
|
||||
});
|
||||
}
|
||||
},
|
||||
|
Reference in New Issue
Block a user