As a total novice, I have created properties for the myGlobalVariables object and set them as empty. My solution involves using TypeScript and numerous React components without incorporating additional frameworks or libraries.
export class Variables extends AbstractService {
static SERVICE_NAME = "service-variables";
private myGlobalVariables: any = {
uploads: [],
anotherObject: {},
anotherArray: [],
}
appendNewProperty(key: string, value) {
\\ need to delete the existing property if it exists
\\ need to add the new property
}
}
The specific item I am looking to add is an object meant for inclusion in the uploads array within myGlobalVariables. The uploads property currently exists as an empty array...my goal is to insert this new object into the array...
{name: "fileA.doc", isComplete: true}
I had intended on importing the Variables class into various .tsx files, as different components may require adding to myGlobalVariables.uploads.
My aim is to maintain generic functionality so that additions can be made to any of the other properties within myGlobalVariables.