Tram-One / tram-one

🚋 Legacy View Framework For Vanilla Javascript
http://tram-one.io/
MIT License
36 stars 8 forks source link

v10: major refactoring #151

Closed JRJurman closed 3 years ago

JRJurman commented 3 years ago

Summary

It's that time of year again where Tram-One gets another major (breaking) refactoring :grin:

Commits are split up to make reviewing easier, here are the overall descriptions for each commit:

v10: linting & jsdoc changes

xo updated, and some of the other changes in the PR caused linting to happen. This commit can be safely ignored.

v10: remove global tramSpace, split up logic for building mounting container

Removing global.tramSpace as a way for people to change where tram-one mounted. This was a strange interface, and locking down to "the window is where data is stored" is probably safer and easier to understand going forward. There was an attempt to get the data to be stored on the top-level element, but because of how components are processed, this was not possible.

Also as part of this commit, the parameter order of start was swapped to be more consistent with other rendering libraries. This also allows us to future proof and potentially make a start function that treats passing in a DOM node or CSS selector as optional, and instead just returns the resulting DOM.

v10: remove useObservable, add useStore

Probably the most significant change in the PR, this change removes the ability to use primitive data in the state hook (e.g. booleans, integers, strings). The reason for this is that useEffect wasn't able to understand when a dependent hook was updated if it was a primitive value. Also, the "two different ways to update state" was probably more confusing than it should have been. To make everything more consistent, the state hook in tram-one now only takes in objects. To make this breaking change more obvious (and because the previous hook name was a little long anyways), the new hook is named useStore.

Also part of this change, updated the interface for useUrlParams. Instead of returning false, it always returns an object, which has a key { matches }

v10: new integration tests

Updated the integration and regression tests to test against a single application. This made it clearer what was being tested, without rebuilding an app every time. This reduced the total number of test components as well.

bump versions, update badges

Bump to version 10, and update the build badges

Checklist