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

前端利器之路由库 #3

Open
SiZapPaaiGwat opened this issue Feb 7, 2015 · 2 comments
Open

前端利器之路由库 #3

SiZapPaaiGwat opened this issue Feb 7, 2015 · 2 comments

Comments

@SiZapPaaiGwat
Copy link
Owner

前端利器之路由库

Crossroads.js

Crossroads.js is a routing library inspired by URL Route/Dispatch utilities present on frameworks like Rails, Pyramid, Django, CakePHP, CodeIgniter, etc... It parses a string input and decides which action should be executed by matching the string against multiple patterns.

It is a powerful and flexible routing system. If used properly it can reduce code complexity by decoupling objects and also by abstracting navigation paths and server requests.

Examples

Finch.js

Finch.js is a whole new take on handling routes in javascript web apps. It utilizes the natural hierarchy of routes, simplified pattern matching, and powerful parameter dependencies in order to speed up and organize web apps that rely highly on interecting with the browser's url.

page.js

Micro client-side router inspired by the Express router.

Sammy

Sammy is a tiny javascript framework built on top of jQuery inspired by Ruby's Sinatra.

PathJS

PathJS is a lightweight, client-side routing library that allows you to create "single page" applications using Hashbangs and/or HTML5 pushState.

Director

Director is a router. Routing is the process of determining what code to run when a URL is requested.

@SiZapPaaiGwat SiZapPaaiGwat changed the title Javascript client side route libraries JavaScript client side route libraries Feb 7, 2015
@SiZapPaaiGwat SiZapPaaiGwat changed the title JavaScript client side route libraries 前端路由库收集 Feb 7, 2015
@SiZapPaaiGwat SiZapPaaiGwat changed the title 前端路由库收集 前端路由库 Feb 7, 2015
@SiZapPaaiGwat SiZapPaaiGwat changed the title 前端路由库 前端利器之路由库 Feb 7, 2015
@SiZapPaaiGwat
Copy link
Owner Author

于是写了个Crossroads.js 的demo,发现了其中的一些主要特点:

  • API接口设计良好,功能强大
  • 已经非常稳定,在论坛、社区很多牛人推荐过。
  • github两年没有更新代码,太稳定了?
  • 依赖较多 ( hasher.js 和signals),和作者追求单一职责原则有关

关于依赖问题,其实我也赞同Crossroads这样的设计,但使用起来实在不顺手。
另外各个组件在接口层面的一致性有问题。比如在设置url的功能上,url是否以/开始会导致一些小问题。
虽然不是什么大问题,但是十分诡异,算得上一个坑。

demo地址

@SiZapPaaiGwat
Copy link
Owner Author

经过最终考虑还是选择了director.js,不过只选择了browser部分

  • 更新频繁,看起来更有生命力
  • 调用简单,使用更顺手
  • route本身的实现并不复杂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant