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

Composition API and Capacitor geolocation #6

Merged
merged 29 commits into from
Apr 23, 2024

Conversation

Carifio24
Copy link
Member

@Carifio24 Carifio24 commented Apr 16, 2024

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 be 0.3.

@Carifio24 Carifio24 marked this pull request as ready for review April 18, 2024 21:02
@Carifio24 Carifio24 merged commit c60df32 into cosmicds:main Apr 23, 2024
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