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

Make 'Navigator.applyCommand()' return boolean to indicate if command was recognized #50

Closed
dimsuz opened this issue Oct 26, 2017 · 1 comment

Comments

@dimsuz
Copy link

dimsuz commented Oct 26, 2017

I believe this would make a better API in terms of composing several navigators.

It would be more natural to do something like this:

class TopNavigator(private val childNavigator: Navigator) : Navigator {
  fun applyCommand(command: Command): Boolean {
    if (childNavigator.applyCommand(command)) {
        // child has handled this command, great!
    } else {
       handleCommandInTopNavigator()
    }
}

With the current implementation returning "void" it is not simple to write above logic, you'd have to resort to some "hacky" ways.

If you are not against this suggestion, I could prepare a PR.

@dimsuz dimsuz changed the title Make 'applyCommand' return boolean to indicate if command was recognized Make 'Navigator.applyCommand()' return boolean to indicate if command was recognized Oct 26, 2017
@dimsuz
Copy link
Author

dimsuz commented Oct 26, 2017

Hmm... I figured that I don't need childNavigator to implement Navigator in this case. So what I was suggesting is not needed actually :)

@dimsuz dimsuz closed this as completed Oct 26, 2017
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

1 participant