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

Refactor rib connector #53

Merged
merged 71 commits into from
May 29, 2019
Merged

Refactor rib connector #53

merged 71 commits into from
May 29, 2019

Conversation

zsoltk
Copy link
Contributor

@zsoltk zsoltk commented May 22, 2019

Lots have changed. The result is a better separation of concerns, easier maintenance, improved understandability (I know there are lots of new concepts, but in total they should be more manageable than the mess what it was before).

  • changed: BackStackFeature only cares about back stack as a list of elements. Has no knowledge about Nodes, RoutingActions, or anything related. All those concerns are extracted.
  • new: ConfigurationCommand describes what needs to be done to a Configuration (reminder: Configuration is what a Node can be in - it is triggered by the actual Interactor implementation, and resolved to RoutingAction in actual Router implementation. Any RoutingAction can result in building Nodes or doing other things, such as showing a dialog, or triggering some lambda, like how we update the menu in SwitcherRouter).
  • new: ConfigurationCommandCreator takes two states of BackStackFeature, calculates the diff, and translates it to a list of ConfigurationCommand objects representing how to get from State0 to State1. This thing needed to be done manually until now, now it's fully automatic.
  • new: ConfigurationFeature cares about executing ConfigurationCommands. It manages a pool of configurations + related Nodes & RoutingActions, without the knowledge of the back stack. All elements are referenced using keys instead. This allows to handle Content-type, Overlay-type, and Permanent parts in a unified way.
  • new: in Router, outputs of the BackStackFeature is connected to the ConfigurationFeature via the diffing done in ConfigurationCommandCreator, resulting in all back stack changes being implemented automatically. The flow is:
    1. back stack manipulation goes to BackStackFeature, a changed list comes out
    2. diff in the changed list gets translated to commands
    3. commands get executed as actual operations in ConfigurationFeature.
  • extra: The above thing means that any back stack operation in the future can be easily implemented by a simple list operation. Everything else is automated! 💯
  • also: Router sometimes triggers global actions directly in ConfigurationFeature regardless of back stack (e.g. all currently on-screen Configurations need to be detached when view is detached, even if the back stack doesn't change)
  • also: the state of both BackStackFeature and ConfigurationFeature are automatically persisted and restored from Bundle
  • changed: every Node related to configurations in the back stack is kept alive, just their views are detached (this hasn't changed). However, after save/restore cycle, only the last element in the back stack is resurrected, the rest is not - they can only get rebuilt as a result of back stack popping getting back to them.
  • new: Permanent parts are now no longer a list of Node builders, but a list of configurations. This is both more powerful (Configuration can be resolved to Node-attaching RoutingAction but also to anything else), and more useful, since then it can be handled the same way as Content or Overlay.
  • new: Overlay is no longer a marker interface, but a generic type, making it compile-time safe to use. The downside is that Router and Interactor has more generic types to know about, but I believe it to be a reasonable trade-off for all the benefits it brings.
  • temporarily removed: support for automatic shrinking of Configurations of all but the last back stack element in case of onLowMemory(). Will add it back later.
  • also: added lots of documentation
  • also: added lots and lots of tests to cover everything described above
  • extra: Implemented support for multiple Overlays (Support multiple Overlays #28) during the ticket. Overlay diffing is also done along with back stack diffing automatically. 🎉

@zsoltk zsoltk added the enhancement New feature or request label May 22, 2019
@ShikaSD
Copy link
Contributor

ShikaSD commented May 22, 2019

yay!

Copy link
Contributor

@Nublo Nublo left a comment

Choose a reason for hiding this comment

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

I will continue reviewing tomorrow, looks like there are a lot of changes and I don't see the big picture.

@zsoltk zsoltk merged commit d952a49 into badoo:master May 29, 2019
@zsoltk zsoltk deleted the refactor-rib-connector branch May 29, 2019 10:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants