Skip to content
This repository was archived by the owner on Jan 21, 2021. It is now read-only.

Conversation

@m1guelpf
Copy link

Looking into the core of Inertia, we might be fine by using a global Inertia instance.

Closes #11

Opened the PR in draft mode because as of right now, we're introducing a dependency on @inertiajs/inertia-vue3 which is not ideal, but I can't think of a way to get access to the usePage() hook without doing so. Ideas welcome.

@driesvints
Copy link
Member

Is this backwards compatible with VueJS v2? And current Jetstream apps?

@m1guelpf
Copy link
Author

@driesvints Since I'm just adding a new method, this should be completely backwards-compatible (when I finish removing the dependency on the vue3 Inertia adapter). The only catch is that users with the vue2 adapter will get an error if they try to use the hook.

@driesvints
Copy link
Member

@m1guelpf I guess that's fine as this is Vue v3 specific.

@m1guelpf
Copy link
Author

I've tested this on a Jetstream vue3 app and a Jestream vue2 app and everything seems to work properly, although I'd appreciate some more vue2 testing before merging this

@m1guelpf m1guelpf marked this pull request as ready for review October 29, 2020 14:51
@taylorotwell
Copy link
Member

@claudiodekker this look OK to you?

@claudiodekker
Copy link

claudiodekker commented Oct 29, 2020

@taylorotwell Yep, looks good to me on first glance 👍

@m1guelpf I'm assuming you tried import { usePage } from "@inertiajs/inertia-vue3" before the current require ...?
(Require loads the whole thing even if you only really need one part, but I'm not sure if my suggestion works inline as well)

@m1guelpf
Copy link
Author

@claudiodekker Imports only work on the top level, and we want this package to work with people using vue 2 too, so that's why there's a conditional and I've added the package to optionalDependencies. Since we need to make a null check, we can't use restructuring as far as I'm concerned.

@m1guelpf m1guelpf marked this pull request as draft October 29, 2020 16:19
@m1guelpf
Copy link
Author

Going back to draft since I've found some issues related to displaying success state

@m1guelpf
Copy link
Author

m1guelpf commented Oct 29, 2020

I've managed to solve the reactivity issue by wrapping the InertiaForm object on a shallowReactive call (which basically adds reactivity to the object without wrapping it in a proxy (see above), which should make this work and also not crash Inertia. The issue is that this, again, introduces a hard dependency on vue 3. Looking into how to fix that now.

@m1guelpf m1guelpf marked this pull request as ready for review October 29, 2020 16:57
@m1guelpf
Copy link
Author

m1guelpf commented Oct 29, 2020

Tested on a Vue 2 app and it doesn't seem to cause any issues, so I'd say it's ready to go 🚀

@taylorotwell taylorotwell merged commit c6eeae3 into laravel:master Oct 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Usage with Vue 3

4 participants