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

Scope name collisions will create weird bevavior/issues, hard to debug #1

Open
Lakedaemon opened this issue Jun 23, 2015 · 1 comment

Comments

@Lakedaemon
Copy link

The way used to name scopes will create awfull issues (hard to understand/debug) :

You shouldn't use the class name for scopes like this :

@OverRide
public Context setUpContext(Path path, Context parentContext) {
MortarScope scope = screenScoper.getScreenScope(parentContext, path.getClass().getName(), path);
return new TearDownContext(parentContext, scope);
}

It took me 1 week to understand that this was causing all the problems I had in my app.
See there :
square/mortar#163

This is related to
square/mortar#149
And a fix was suggested upstream there :
square/mortar#161

@Lakedaemon Lakedaemon changed the title Scope name collisions will create weird bevaviro/issues, hard to debug Scope name collisions will create weird bevavior/issues, hard to debug Jun 23, 2015
@lukaspili
Copy link
Owner

This is a very simple example where each screen is unique in the scope graph, and thus the class name is fine as naming policy.

The screen adapter for the view pager use another policy for scope naming, in order to avoid collision: https://github.com/lukaspili/Mortar-Flow-Dagger2-demo/blob/master/app/src/main/java/com/lukaspili/mortardemo/app/adapter/SlidePagerAdapter.java

Also, you may want to check my lib Mortar-architect, which is a kind of replacement of Flow. I use there a ScopeNamer that tracks names of scopes, and ensures they are unique, while still being saved & restored in order to survive process kill:
https://github.com/lukaspili/Mortar-architect/blob/master/architect/src/main/java/architect/ScopeNamer.java

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

No branches or pull requests

2 participants