Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: lazy preference proxy #9169

Merged
merged 1 commit into from
Mar 17, 2021
Merged

core: lazy preference proxy #9169

merged 1 commit into from
Mar 17, 2021

Conversation

paul-marechal
Copy link
Member

It is possible to register a preference schema to the
PreferenceSchemaProvider after the initial inversify binding phase.
This is problematic when wanting to do that late schema registration and
at the same time trying to bind a preference proxy because proxies must
be bound early on.

This commit fixes the issue by allowing createPreferenceProxy to
process a promise for its schema parameter (now promisedSchema) and
still return a proxy synchronously. Until the promise resolves, most
operations on the proxy will be no-ops.

How to test

See added tests.

Review checklist

Reminder for reviewers

@paul-marechal paul-marechal added preferences issues related to preferences core issues related to the core of the application labels Mar 9, 2021
@paul-marechal
Copy link
Member Author

cc @dukengn

@paul-marechal
Copy link
Member Author

paul-marechal commented Mar 9, 2021

My approach is to keep returning proxies synchronously so that they can be bound using Inversify, but the the returned proxy will perform no-ops until the schema is resolved.

It is possible to register a preference schema to the
`PreferenceSchemaProvider` after the initial inversify binding phase.
This is problematic when wanting to do that late schema registration and
at the same time trying to bind a preference proxy because proxies must
be bound early on.

This commit fixes the issue by allowing `createPreferenceProxy` to
process a promise for its `schema` parameter (now `promisedSchema`) and
still return a proxy synchronously. Until the promise resolves, most
operations on the proxy will be no-ops.

Signed-off-by: Paul Maréchal <[email protected]>
Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I verified the changes and confirmed there are no regressions, we are now able to specify proxies dynamically. The unit and api tests successfully pass as well 👍

Copy link
Contributor

@DucNgn DucNgn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look good to me 👍
The test suite passes and I also verified that operations on the proxy work properly once the promise resolved.

@paul-marechal paul-marechal merged commit 9dacd49 into master Mar 17, 2021
@paul-marechal paul-marechal deleted the mp/lazy-preference-proxy branch March 17, 2021 19:44
@github-actions github-actions bot added this to the 1.12.0 milestone Mar 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core issues related to the core of the application preferences issues related to preferences
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants