loteoo / hyperstatic

Routing, prerendering, code splitting and prefetching for hyperapp
https://hyperstatic.dev/
MIT License
59 stars 5 forks source link

replace pushstate event with chained effect #9

Closed skipkayhil closed 4 years ago

skipkayhil commented 4 years ago

Hello again,

I've been looking into more ways to optimize Hyperstatic, and I while this is a small change I think it reduces code complexity in a good way. While the popstate event is fired by the browser (on browser back button), pushstate is only fired by the ChangeLocation effect. Instead of firing the event in the effect, I think it is a lot more clear to use the ParseUrl action in Navigate and only have the ChangeLocation effect update the history.

This PR is probably a little more opinionated than the last one (especially with function names), and I'm willing to make any changes you suggest.

loteoo commented 4 years ago

Hello @SkipKayhil, thank you for this PR!!

I agree with your changes, the state updates are now more direct.

Hopefully I will be able to work on hyperstatic soon 🙏 I want to see if it's possible to remove the dependency on the lifecycle events from the library, since it's not in line with hyperapp's way of doing things.

I will test & merge it over the weekend, thanks!!