Skip to content

2.0.0-beta.1 - Better Design

Pre-release
Pre-release
Compare
Choose a tag to compare
@rakuyoMo rakuyoMo released this 09 Sep 05:50
· 21 commits to master since this release

While using "RaRouter`1.x", we found a lot of problems, some of which were caused by some wrong design.

So in 2.x version, we have refactored some of the content and tried to fix some of the issues.

Version 2.0.0 is still in preparation, so if you have any suggestions, or if you find bugs, please let us know.

Change

The following changes are essentially to the definition of the module and require little or no change for the caller.

Version restrictions

The minimum version requirement for 2.x has now been raised to iOS 10..

Factory

Factory related content is the biggest change.

  • RouterFactory is now a protocol instead of a class.
  • FactoryMediator protocol has been added to decouple and register routes.
  • ModuleRouter adds an associated Factory type, following the RouterFactory protocol.

Table

  • RouterTableProtocol has been renamed to RouterTable.
  • String and String enumeration now follow RouterTable Protocol default.
  • RouterError has added an error of type tableNil.

Execute Router

  • the three ways of performing routing in RaRouter **no longer accept **String as a valid route url.
  • Also, the table parameter is marked as Optional. A RouterError.tableNil is thrown when the passed table is nil.

If you need to perform routing via the native string type, convert the type manually.
For example: Module.Table(rawValue: "your router url").

We are still evaluating this change. For more information, please refer to. #16

Initialize

  • Added NeedInitialized protocol.
  • Gave the RaRouter<Global>.initialize() method a completely different functionality than before.

The new version of RaRouter does not require additional registration logic**, i.e., there is no need to execute Router<Modules>.initialize() in the application(_:didFinishLaunchingWithOptions:) method.

That's a good thing, it means no extra code needs to be written.

But this also means a problem: the module has lost the ability to sense app startup.

While we can also use the "UIApplicationDidFinishLaunchingNotification" notification to sense that the app has finished launching, we wish there was a way for us to more accurately control this process.

So we provide the NeedInitialized protocol and the RaRouter<Global>.initialize() method.

TODO

Next, in addition to fixing bugs, we will focus more on how to simplify the definition of modules and how to improve routing performance.

These changes may be released with "2.0.0", or in a future "2.x" release.