diff --git a/README.md b/README.md index 4c0e07f7..7a40f486 100644 --- a/README.md +++ b/README.md @@ -91,21 +91,20 @@ openmct.install(installYamcsPlugin({ | yamcsInstance | The name of the instance configured in YAMCS that you wish to connect to. | myproject | | yamcsFolder | The name of the instance configured in YAMCS that you wish to connect to. | myproject | -## dictionaryRequestCacheStrategyPromise -installYamcsPlugin also accepts an optional promise argument `dictionaryRequestCacheStrategyPromise`. This strategy is passed to the request for loading the YAMCS dictionary, or the `#loadTelemetryDictionary` function in `object-provider.js`. An example of how to make use of this is below. +## getDictionaryRequestOptions +installYamcsPlugin also accepts an optional function argument `getDictionaryRequestOptions`. Use this function to return request options when requesting the YAMCS dictionary. An example of how to make use of this is below. ``` -let cacheStrategy; -const cacheStrategyPromise = new Promise(resolve => cacheStrategy) - openmct.install(installYamcsPlugin( configuration, - cacheStrategryPromise + getDictionaryRequestOptions )) -if (DICTIONARY_VERSION_IS_NEW) { // some check to determine dictionary version - cacheStrategy({cache: 'reload'}) -} else { - cacheStrategy({}) +function getDictionaryRequestOptions() { + const requestOptions = SOME_CHECK_IF_DICTIONARY_VERSION_IS_NEW + ? { cache: 'reload' } + : {}; + + return requestOptions; } ``` diff --git a/src/openmct-yamcs.js b/src/openmct-yamcs.js index 249d19e9..2fb4dfd2 100644 --- a/src/openmct-yamcs.js +++ b/src/openmct-yamcs.js @@ -40,7 +40,7 @@ import ExportToCSVActionPlugin from './actions/exportToCSV/plugin.js'; export default function install( configuration, - dictionaryRequestCacheStrategyPromise + getDictionaryRequestOptions ) { return (openmct) => { openmct.install(openmct.plugins.ISOTimeFormat()); @@ -133,7 +133,7 @@ export default function install( pollQuestionTelemetry, realtimeTelemetryProvider, configuration.yamcsProcessor, - dictionaryRequestCacheStrategyPromise + getDictionaryRequestOptions ); openmct.objects.addRoot({ diff --git a/src/providers/object-provider.js b/src/providers/object-provider.js index 81891a49..48f9d42c 100644 --- a/src/providers/object-provider.js +++ b/src/providers/object-provider.js @@ -39,7 +39,7 @@ const YAMCS_API_MAP = { const operatorStatusParameter = new OperatorStatusParameter(); export default class YamcsObjectProvider { - constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime', dictionaryRequestCacheStrategyPromise = Promise.resolve({})) { + constructor(openmct, url, instance, folderName, roleStatusTelemetry, pollQuestionParameter, pollQuestionTelemetry, realtimeTelemetryProvider, processor = 'realtime', getDictionaryRequestOptions = () => Promise.resolve({})) { this.openmct = openmct; this.url = url; this.instance = instance; @@ -52,7 +52,7 @@ export default class YamcsObjectProvider { this.dictionary = {}; this.limitOverrides = {}; this.dictionaryPromise = null; - this.dictionaryRequestCacheStrategyPromise = dictionaryRequestCacheStrategyPromise; + this.getDictionaryRequestOptions = getDictionaryRequestOptions; this.roleStatusTelemetry = roleStatusTelemetry; this.pollQuestionParameter = pollQuestionParameter; this.pollQuestionTelemetry = pollQuestionTelemetry; @@ -194,7 +194,8 @@ export default class YamcsObjectProvider { const operation = 'parameters?details=yes&limit=1000'; const parameterUrl = this.url + 'api/mdb/' + this.instance + '/' + operation; const url = this.#getMdbUrl('space-systems'); - const requestOptions = await this.dictionaryRequestCacheStrategyPromise; + + const requestOptions = await this.getDictionaryRequestOptions(); const spaceSystems = await accumulateResults(url, requestOptions, 'spaceSystems', []); const parameters = await accumulateResults(parameterUrl, requestOptions, 'parameters', []);