All Projects → kyleduo → Rabbits

kyleduo / Rabbits

Licence: apache-2.0
A router module for Android application.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Rabbits

Xunleikuainiaoinshell
[ 迅雷快鸟 Shell 版 ] A Shell Implementation of Kuainiao, Xunlei
Stars: ✭ 102 (-13.56%)
Mutual labels:  router
Pilot
Pilot — multifunction JavaScript router.
Stars: ✭ 109 (-7.63%)
Mutual labels:  router
Netcopa
Network Configuration Parser
Stars: ✭ 112 (-5.08%)
Mutual labels:  router
Router
A simple, compact and fast router package to process HTTP requests
Stars: ✭ 102 (-13.56%)
Mutual labels:  router
Gin
Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
Stars: ✭ 53,971 (+45638.14%)
Mutual labels:  router
Php Router
simple and flexible Router class for PHP. with Controllers and Middlewares support.
Stars: ✭ 111 (-5.93%)
Mutual labels:  router
Iceworld
tonado的multi-thread 多线程封装
Stars: ✭ 99 (-16.1%)
Mutual labels:  router
Alien
A lightweight and fast http router from outer space
Stars: ✭ 115 (-2.54%)
Mutual labels:  router
Docker Openwrt
OpenWrt running in Docker
Stars: ✭ 107 (-9.32%)
Mutual labels:  router
Rxviper
Android micro framework for developing apps based on clean VIPER architecture.
Stars: ✭ 112 (-5.08%)
Mutual labels:  router
Cottage
Simple, fast HTTP router on koa.js.
Stars: ✭ 103 (-12.71%)
Mutual labels:  router
Router.js
Router.js is a simple and powerful javascript library to handle routing
Stars: ✭ 107 (-9.32%)
Mutual labels:  router
Sme Router
A lightweight router lib that implement with express route style
Stars: ✭ 112 (-5.08%)
Mutual labels:  router
Routes
typed bidirectional routes for OCaml/ReasonML web applications
Stars: ✭ 102 (-13.56%)
Mutual labels:  router
Router
🍭灵活的组件化路由框架.
Stars: ✭ 1,502 (+1172.88%)
Mutual labels:  router
Pc Engines Apu Router Guide
Guide to building a Linux or BSD router on the PC Engines APU platform
Stars: ✭ 101 (-14.41%)
Mutual labels:  router
Scalajs React
Facebook's React on Scala.JS
Stars: ✭ 1,524 (+1191.53%)
Mutual labels:  router
React Page Layout
Create layouts for react
Stars: ✭ 117 (-0.85%)
Mutual labels:  router
Tieguanyin
Activity Builder.
Stars: ✭ 113 (-4.24%)
Mutual labels:  router
Core
UI-Router Core: Framework agnostic, State-based routing for JavaScript Single Page Apps
Stars: ✭ 112 (-5.08%)
Mutual labels:  router

Rabbits

中文 README Blog

NOTICE Rabbits has a lot of changes after version 1.0.0. If you’re using Rabbits, read wiki before update.

version

Demo

Download Link

preview

Quick Glance

@Page(value="/test", alias="TEST_ACT", variety=["/test_variety", "/test/{param}"])
public class TestActivity extends AppCompatActivity {}

// somewhere else
public class MainActivity extends AppCompatActivity {
  public void onButtonClicked() {
    // every statement works same
    Rabbit.from(this).to(P.TEST_ACT).putExtra("param", "value").start();
    Rabbit.from(this).to("/test?param=value").start();
    Rabbit.from(this).to(P.P_TEST_PARAM("value")).start();
  }
}

Changes in version 1.0.0

I released Rabbits last year and have been using it since then. Everything works fine and the “From-To-Start” pattern make me almost forget the new Intent() stuff. Rabbits simplify the navigation between pages hosted by Activities and Fragments and, with URI as the protocol, navigation between web pages and native pages becomes easier.

Even though the usage is easier and intuitive, I found some which can be improved. There are 3 points which are more important.

  1. mappings.json. When I first design Rabbits, I design by separating App client from the backend. But in practice, it’s much reasonable and flexible to let backend control the behavior of App.
  2. Interceptor. Interceptor is important when you need to control the process of navigation, adding some params or redirecting to another page. It looks silly that you need check whether the url is the one you want when using Interceptor. The condition of url should be bound to the interceptor so only the urls you want can enter the process method, which is that logical.
  3. obtain. It’s not consistent when you try to obtain a Fragment object using Rabbits since the towering obtain API.

Therefore, I’ve rethought the design of Rabbits and browsed other router libraries to learn what is really needed of a router. However, my decision is to keep Rabbits simple and make it’s usage much more easier. Rabbits 1.0.0 focus just one thing, navigation through pages.

Since I redesigned Rabbits from the bottom. Almost all of the APIs have changed. I’m going to list some significant and obvious change below, the others about the new version can be found in wiki.

  1. mappings.json has been removed. You need to annotated name on every page’s class. @Page() has changed and you can use it like this: @Page("/page/path").
  2. Initialization API has changed a lot but the new API becomes more fluent and you can finish the initialization by a single link of invocations.
  3. P class is still there. Since mappings.json is gone so Rabbits generate P using url path specified in @Page or you can provide a alias field to name that page a friendly name. Field generated from a path may looks like this: P_PAGE_PATH. Yes, there is a prefix, P_.
  4. The execution chain has been redesigned and interceptors are recommended set during initialization phase.
  5. Usage of in multiple-module become so easy and dependency between modules in different layers become less.

Use with Gradle

dependencies {
    implementation "com.kyleduo.rabbits:rabbits:{latest-version}"
    annotationProcessor "com.kyleduo.rabbits:compiler:{latest-version}"
}

From-To-Start pattern

The From-To-Start pattern is quite simple and intuitive since navigation is just from on page to another.

// MainActivity.java
Rabbit.from(this).to(P.P_TEST).start();

ProGuard rules

Since Rabbits generate routing table in compile phase and no reflection during navigation, you just need add this line in your ProGuard rules file.

-keep class com.kyleduo.rabbits.Router { *; }

Migration

If you have been using Rabbits before 1.0.0, read the wiki first before update.

Thanks

OKHttp: I learnt how to implement interceptor chain from OKHttp.

ARouter: The ideaflags is from ARouter.

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].