mirror of
https://github.com/nasa/openmct.git
synced 2025-04-09 12:21:25 +00:00
feat: hook up event listeners
This commit is contained in:
parent
d0c9d8b07d
commit
4047014f87
@ -32,6 +32,7 @@ export default class StatusAPI extends EventEmitter {
|
||||
|
||||
this.onProviderStatusChange = this.onProviderStatusChange.bind(this);
|
||||
this.onProviderPollQuestionChange = this.onProviderPollQuestionChange.bind(this);
|
||||
this.onMissionRoleStatusChange = this.onMissionRoleStatusChange.bind(this);
|
||||
this.listenToStatusEvents = this.listenToStatusEvents.bind(this);
|
||||
|
||||
this.#openmct.once('destroy', () => {
|
||||
@ -40,6 +41,7 @@ export default class StatusAPI extends EventEmitter {
|
||||
if (typeof provider?.off === 'function') {
|
||||
provider.off('statusChange', this.onProviderStatusChange);
|
||||
provider.off('pollQuestionChange', this.onProviderPollQuestionChange);
|
||||
provider.off('missionRoleStatusChange', this.onMissionRoleStatusChange);
|
||||
}
|
||||
});
|
||||
|
||||
@ -316,6 +318,7 @@ export default class StatusAPI extends EventEmitter {
|
||||
if (typeof provider.on === 'function') {
|
||||
provider.on('statusChange', this.onProviderStatusChange);
|
||||
provider.on('pollQuestionChange', this.onProviderPollQuestionChange);
|
||||
provider.on('missionRoleStatusChange', this.onMissionRoleStatusChange);
|
||||
}
|
||||
}
|
||||
|
||||
@ -332,6 +335,13 @@ export default class StatusAPI extends EventEmitter {
|
||||
onProviderPollQuestionChange(pollQuestion) {
|
||||
this.emit('pollQuestionChange', pollQuestion);
|
||||
}
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
onMissionRoleStatusChange(role, newStatus) {
|
||||
this.emit('missionRoleStatusChange', role, newStatus);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,12 +23,12 @@ import UserProvider from './UserProvider.js';
|
||||
|
||||
export default class StatusUserProvider extends UserProvider {
|
||||
/**
|
||||
* @param {('statusChange'|'pollQuestionChange')} event the name of the event to listen to
|
||||
* @param {('statusChange'|'pollQuestionChange'|'missionRoleStatusChange')} event the name of the event to listen to
|
||||
* @param {Function} callback a function to invoke when this event occurs
|
||||
*/
|
||||
on(event, callback) {}
|
||||
/**
|
||||
* @param {('statusChange'|'pollQuestionChange')} event the name of the event to stop listen to
|
||||
* @param {('statusChange'|'pollQuestionChange'|'missionRoleStatusChange')} event the name of the event to stop listen to
|
||||
* @param {Function} callback the callback function used to register the listener
|
||||
*/
|
||||
off(event, callback) {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user