hyperoslo / Compass

:earth_africa: Compass helps you setup a central navigation system for your application
http://hyper.no
Other
825 stars 47 forks source link

Compass 3.0.0 #33

Closed vadymmarkov closed 8 years ago

vadymmarkov commented 8 years ago

@zenangst @RamonGilabert @onmyway133 We kinda like to break Compass from time to time, so it's a brand new breaking change 😄

1) Remove Compass.parse completion closure in favour of Location struct:

So instead of:

func application(app: UIApplication,
  openURL url: NSURL,
  options: [String : AnyObject]) -> Bool {
    return Compass.parse(url) { route, arguments in
      switch route {
        case "profile:{username}":
          let profileController = profileController(title: arguments["{username}"])
          self.navigationController?.pushViewController(profileController, animated: true)
        default: break
      }
    }
}

We unwrap optional Location:

func application(app: UIApplication,
  openURL url: NSURL,
  options: [String : AnyObject]) -> Bool {
    guard let location = Compass.parse(url) else {
      return false
    }

    let arguments = location.arguments

    switch location.path {
      case "profile:{username}":
        let profileController = profileController(title: arguments["{username}"])
        self.navigationController?.pushViewController(profileController, animated: true)
      default: break
    }

    return true
}

The advantage of this approach is that Compass.parse is not async anymore, we get the needed result straight away and can handle the case when urn could not be parsed.

2) Refactor Router and Routable to support Mac by using type aliases. 3) Route path, arguments and fragments are scoped by Location struct. Makes it easier to add more properties in the future. 4) We used only 2 String methods from Sugar and I feel like it's unnecessary to hold this dependency, especially thinking about Swift 3 where it's no longer actual. So... we don't use Sugar in Compass anymore 😄 5) Refactor project structure to be prepared to Swift Package Manager. 6) Add Swiftlint, mention-bot and update Travis config.

mention-bot commented 8 years ago

@vadymmarkov, thanks for your PR! By analyzing the annotation information on this pull request, we identified @zenangst, @jessearmand and @onmyway133 to be potential reviewers

jessearmand commented 8 years ago

I agree with those ideas. I have removed Sugar as a dependency as well in my own fork.

vadymmarkov commented 8 years ago

Well, seems like it's gonna be v3 because the last released is v2. We just had a wrong one in Podspec.

onmyway133 commented 8 years ago

🎸 🎶 🎶

zenangst commented 8 years ago

This is grrreeeeat!

young-shaq-dancing-shaq-gifs