-
Notifications
You must be signed in to change notification settings - Fork 4
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
Composition API and Capacitor geolocation #6
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ctor functionality into composables.
…bly unhelpful error message.
… Is there a better solution?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the toolkit to use Vue's Composition API. This is a pretty significant change that will impact the way that we structure our Vue-based stories. With that said, a lot of the logic of the way we think about our reactive quantities is still valid, and I think the added flexibility that we'll get is well worth the price.
The main new concept here is composables. The linked documentation has a very nice example, but the basic idea is that a composable is a function that manages, and allows us to reuse, stateful logic. As the linked example shows, with the Composition API, we can use lifecycle hooks inside composables, allowing for completely encapsulated handling of the exposed reactive items. Basically they're mixins, but without having to worry about hierarchy.
We've also discussed building mobile app versions of the CosmicDS Vue stories. Something that moves us in that direction without requiring very much extra bandwidth is to use Capacitor, which allows us to build calls to native platform services directly into our Vue code. From having experimented with it, the generated applications require a little extra work to be ready to go, but I can handle myself that until I set up a more automated way to manage things. As a first step in that direction, this PR updates the geolocation button to use Capacitor's geolocation feature. This is actually a bit of a complicated example as I had to work around some issues with their web implementation, but we're able to hide all of that behind a composable one time and never need to worry about it again.
I'm marking this as a draft as I need to finish testing out all of these reworked components, and I'll have a similar PR soon for the template that will use this updated version of the toolkit. Note that since our stories pull in the toolkit via NPM, we don't need to worry about compatibility as they should already be pinned to older versions (I believe they're mostly pinned to
^0.2
; I'm imagining that the next release will be0.3
.