Re: Ideas to store add-on state.

James Scholes

If you have state that only needs to be utilised during the add-on's runtime, and not persisted, I would just store it on the AppModule or GlobalPlugin instance:

class AppModule(appModuleHandler.AppModule):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._someStateFlag = False
self._someOtherStateFlag = 14
# or
self._state = {'flag1': False, 'flag2': 14}

Is there a reason why this wouldn't be sufficient?


James Scholes

On 21/06/2022 at 11:20, Pawel Urbanski wrote:
Dear Everyone,
Since I still occasionally use Visual Studio Code and nobody followed
up with my request to take over the development, I am working on
updating the add-on.
I am looking for hints and inspiration on how to best keep add-on
state. It does not need to be saved but needs to work when the
application is running. I use it to store some add-on flags and state.
Is there anything in NVDA api like this or maybe you cane up with a
working way to share global state. There is the configuration class
but I don't know if it can be made local to the add-on running
instance in the scope of the AppModule class - please treat this
example as explanatory not in terms of working code.

Thank you for any hints...

Join to automatically receive all group messages.