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

ScopeProvider isn't considered when the ViewModel isn't injected into it's view #513

Open
manuel-mauky opened this issue Aug 21, 2017 · 0 comments

Comments

@manuel-mauky
Copy link
Collaborator

When a ViewModel with a @ScopeProvider annotation is not injected into it's View, the annotation is not considered for scope creation.
See the following example:

public class MyScope implements Scope {
}
@ScopeProvider(scopes= {MyScope.class})
public class ParentViewModel implements ViewModel {
}
public class ParentView implements FxmlView<ParentViewModel> {
}
public class ChildViewModel implements ViewModel {

    @InjectScope
    private MyScope scope;

}
public class ChildView implements FxmlView<ChildViewModel> {
}

This configuration should work. Instead, trying to load ParentView results in an Exception telling you that no provider for MyScope was found. As a workaround you have to adjust ParentView like this:

public class ParentView implements FxmlView<ParentViewModel> {
    @InjectViewModel
    private ParentViewModel viewModel;
}

This prevents the exception. The reason for this is that durring the loading process the scopeProvider annotation isn't considered because the ViewModel is not used in the View. This is a bug. It shouldn't be neccessary to inject the ViewModel instance into the View to make scopes work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant