reagent-project / reagent-template

A Leiningen template for projects using Reagent.
MIT License
394 stars 55 forks source link

nearly isomorphic routing with accountant library #88

Closed edvorg closed 8 years ago

edvorg commented 8 years ago

This idiomatic change suggest to use accountant library for client-side rounting configuration. The main idea is to use non-fragment hrefs and handle clicks via dom events. If browser is capable enough and routes for href path is present, page will not cause reloading.

You may see an example at http://isomorph.clj.rocks . No matter, which browser you use - firefox, chrome or links. It will be routed correctly.

Changes summary:

Frozenlock commented 8 years ago

FWIW, this breaks the middle-click and the ctrl-click (open in a new tab).

edvorg commented 8 years ago

Ahh. Didn't know that. May be author have workaround @venantius

edvorg commented 8 years ago

But does it really matter for reagent applications?

Frozenlock commented 8 years ago

Well yes...

If you use Reagent to create something for the browser, you absolutely don't want to break normal browser behavior.

edvorg commented 8 years ago

I found the solution and will make a pr to accountant soon. https://developer.mozilla.org/en/docs/Web/Events/click But what do you think about this idea in general?

Frozenlock commented 8 years ago

I have no strong opinion about it. I guess @yogthos is in a better position to comment on this.

Personally I use Bidi in my projects.

edvorg commented 8 years ago

fixed in accountant https://github.com/venantius/accountant/pull/9

yogthos commented 8 years ago

@edvorg I agree with @Frozenlock that breaking default browser behavior as the default wouldn't be desirable, but since it looks like that issue has been fixed the pr looks good to me

yogthos commented 8 years ago

I'd wait once the change is merged, and then could release against the latest version of accountant

venantius commented 8 years ago

I've merged the change to Accountant and pushed up a new version, 0.1.4, that includes it.

edvorg commented 8 years ago

Upped version, redeployed example to make sure it works.

yogthos commented 8 years ago

:+1:

yogthos commented 8 years ago

and up on Clojars