Skip to content

Conversation

friday
Copy link
Member

@friday friday commented May 31, 2022

In v5, the way extension developers handle preferences being loaded initially was to subscribe to the PreferencesEvent. This PR adds a much better way (so we can remove this event in the future).

It's now done in the Extension.__init__ method. This makes things less confusing for users, without multiple extension init events/methods, and this way the extension will be able to access the preferences as soon as it's created, without delays/waiting.

class MyExtension(Extension):
    def __init__(self):
        super().__init__()
        value = self.preferences.get('my_preference_id')

It is sending the whole preferences object as stringified json in an environment variable, then loads it again. It might be inefficient, but the object is small and should be fast to format and parse.

Checklist

  • Verify that the test command ./ul test is passing (the CI server will check this if you don't)
  • Update the documentation according to your changes (when applicable)
  • Write unit tests for your changes (when applicable)

@friday friday added this to the 6.0.0 milestone May 31, 2022
@friday friday merged commit 61af4c9 into v6 May 31, 2022
@friday friday deleted the preload-ext-preferences-b branch May 31, 2022 11:16
@friday friday mentioned this pull request May 31, 2022
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant