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

Migrate from railsware/js-routes to ElMassimo/js_from_routes #2

Merged
merged 1 commit into from
Feb 5, 2021

Conversation

ElMassimo
Copy link
Owner

@ElMassimo ElMassimo commented Feb 5, 2021

Description 📖

This pull request is an example on how to migrate from js-routes, which does not allow code splitting or customization, to js_from_routes which allows to leverage routes to generate code as needed.

As a result we go from this with js-routes:

this.$inertia.put(this.$routes.restore_contact(this.contact.id))

to this with js_from_routes:

ContactsRequests.restore(this.contact)

It requires no additional runtime dependencies, the generated code is smaller and code-splittable, and it supports ESM imports and TypeScript.

Notes ✏️

In this example, we use a custom template, and modify it to use Inertia and Inertia.form to perform the requests.

The same error checking takes place, and a nice error message will be printed if URL parameters are missing.

Notice how the generated code is way more readable, and yet requires less lines of code.

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

Successfully merging this pull request may close these issues.

1 participant