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

Library registration for service location #42

Merged
merged 3 commits into from
Feb 12, 2014
Merged

Conversation

anaisbetts
Copy link
Member

For libraries that want to base themselves on Splat's service locator, making sure your types are registered properly is annoyingly difficult, and ends up pushing the problem to the user, where today, if you set the locator in your app with RxUI and Akavache, you now have to run:

Locator.CurrentMutable = new MyCoolLocator();
Locator.CurrentMutable.InitializeSplat();
Locator.CurrentMutable.InitializeReactiveUI();
Locator.CurrentMutable.InitializeAkavache();

Instead, this PR adds a way for libraries to get called back when they have a new resolver to set up:

RegisterResolverCallbackChanged(() => {
    if (Locator.CurrentMutable == null) return;
    Locator.CurrentMutable.InitializeSplat();
});

You'd call this in either a static constructor of your library (if you can), or in a Module Initializer if you really want to be sure.

@shiftkey
Copy link
Contributor

👍

anaisbetts pushed a commit that referenced this pull request Feb 12, 2014
Library registration for service location
@anaisbetts anaisbetts merged commit 47f3bb8 into master Feb 12, 2014
@anaisbetts anaisbetts deleted the libregistration branch February 12, 2014 21:57
@lock lock bot locked and limited conversation to collaborators Jun 25, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants