ssorallen / turbo-react

A JavaScript library that transitions between static HTML pages on navigation; no app server required.
https://turbo-react.herokuapp.com/
Apache License 2.0
274 stars 16 forks source link

Turbolinks 5 #28

Closed glennfu closed 7 years ago

glennfu commented 8 years ago

I remember when first tinkering with this project, I was super excited about the concept. Turbolinks 5 is basically dancing behind the curtain now just itching to be unveiled. Have you taken a look at it lately to see about re-writing turbo-react for the latest Turbolinks?

ssorallen commented 8 years ago

@glennfu I have not had the chance to investigate Turbolinks 5 yet. turbo-react relies on an ugly monkeypatch and knowledge of implementation details of Turbolinks. A major version bump likely means the core of turbo-react will need to be reconsidered.

Have you had the chance to look at it? Got any interesting feedback?

glennfu commented 8 years ago

It's a combination of 1: a simpler approach to usage, where all that happens is you either visit a page as normal, or replace the page without a history change. That's like, everything. Then it comes down to the minor quirks of how to deal with corner cases that don't work immediately as you expect. Then the other side is 2: a crazy wrapper for iOS and Android to take the page transitions and make them feel like native app transitions, while giving you a hook into making JS calls to the native app so you can have your native code respond there for things like, adding a button in the nav bar.

Looking into where turbo-react might come into play, it looks like the core rendering methods are here: https://github.com/turbolinks/turbolinks/blob/master/src/turbolinks/snapshot_renderer.coffee#L50

So we have some parentNode.replaceChild calls and one document.body = @newBody. The trick will be, of course, not breaking any of the magic that Turbolinks is trying to quietly do for you. Monkey patching as a proof of concept should now be easier imo, and similarly a pull request for better hooks should be cleaner, too, once it can be proven that turbo-react is viable here.

I still think this project will be really valuable here. The ability to have css transitions between state changes with basically 0 effort is still really awesome.

glennfu commented 8 years ago

Just pushed this, seems to work! https://github.com/ssorallen/turbo-react/pull/29