Is there an official mechanism to set/get keys on the Window object besides directly assigning values with window.myValue = 'something'
? I'm looking for a method similar to:
window.setValue('myKey', 'myValue')
window.getValue('myKey')
My goal is to apply dependency inversion by creating an interface that interacts with the Window object.
interface GetterSetter {
setValue(key: string, value: any): void
getValue(key: string): any
}
function addHi(target: GetterSetter) {
target.setValue('Hi', 'Marco')
}
addHi(window)