Zhuinden / simple-stack

[ACTIVE] Simple Stack, a backstack library / navigation framework for simpler navigation and state management (for fragments, views, or whatevers).
Apache License 2.0
1.37k stars 74 forks source link

Figure out if current semantics of serviceBinder.canFindService/lookupService is correct #180

Closed Zhuinden closed 5 years ago

Zhuinden commented 5 years ago

Apparently this wasn't tested as much as I probably should have... as I thought that canFindService/lookupService skips the services added in the ServiceBinder, and only searches in the parent scopes.

However, apparently because of https://github.com/Zhuinden/simple-stack/blob/a6070d99695b2881d32eefb72e75467a41538fc7/simple-stack/src/main/java/com/zhuinden/simplestack/ScopeManager.java#L114

The scope that is being built is already an "active scope", and returns the service!

I'm actually not sure which variant makes more sense. To be fair, I also thought that it might be tricky that get finds something and lookup does not, so maybe I just got lucky (and this is a problem that is coincidentally already solved). 🤔

Zhuinden commented 5 years ago

It's actually well-tested and defined in https://github.com/Zhuinden/simple-stack/blob/5b90e359bf67815676e72d80c6cdbf63c2427ea0/simple-stack/src/test/java/com/zhuinden/simplestack/ScopingTest.java#L701-L707