v2.0.0-pre.18
Migrate from Feathers-Pinia v0.x
🚧 CAUTION 🚧
If you're going to try out the pre-release, make sure you lock the version number in your package.json.
Once you've installed version 2.0 (currently with npm i feathers-pinia@pre) you'll need to make the following changes.
Switch to Model Functions
Since this process is very similar for Feathers-Pinia and Feathers-Vuex users, it has its own page. See the page on Migrating Models.
Switch handleClones to useClones
Since this process is very similar for Feathers-Pinia and Feathers-Vuex users, it has its own page. See the page on Migrating handleClones.
Don't Worry About __isClone
There's no need to manually remove __isClone or other instance metadata in hooks. They are now added as a non-enumerable values, so they won't show up during instance serializion when prepping to send to the API server.
No debounceEventsMaxWait
TLDR: If you were using it, replace debounceEventsMaxWait with debounceEventsGuarantee.
In order to reduce file size, we have removed lodash's debounce from the package. Lodash's debounce supported custom intervals for guaranteed execution. The replacement package, just-debounce does not support a custom interval for guarantee. You can still guarantee execution by setting debounceEventsGuarantee: true in the options. This shouldn't break any apps since the guaranteed interval will only be made shorter.
tempIdField Not Configurable
The tempIdField is no longer configurable and is hard-coded to __tempId. When you create an instance without an idField, a __tempId will automatically be assigned.
Global State Exports Removed
Any API involving global state has been removed. This includes
- the
clientsexport - the
modelsexport
Service Store Changes
clientAliashas been removed.servicePathhas been removed. Pass theserviceobject, instead.tempIdFieldhas been removed. The value is hard-coded to__tempId.eventLocksByIdhas been renamed toeventLocks.pendingByIdhas been split into several objects by method name:createPendingByIdupdatePendingByIdpatchPendingByIdremovePendingById
afterFindhas been removed. You can use Feathers Client hooks instead.statehas been removed. Usesetupstores, instead. See Customize the Store.methodshas been removed. Usesetupstores, instead. See Customize the Store.actionshas been removed. Usesetupstores, instead. See Customize the Store.
No More defineAuthStore
The useAuth utility is the replacement for defineAuthStore. It's much more powerful and flexible.
ts
// src/stores/auth.ts (old way)
import { defineAuthStore } from 'feathers-pinia'
import { api as feathersClient } from '~/feathers'
export const useAuth = defineAuthStore({
feathersClient,
})
ts
// src/stores/auth.ts (new way)
import { defineStore, acceptHMRUpdate } from 'pinia'
import { useAuth } from 'feathers-pinia'
export const useAuthStore = defineStore('auth', () => {
const { api } = useFeathers()
const userStore = useUserStore()
const utils = useAuth({ api, userStore })
utils.reAuthenticate()
return { ...utils }
})
if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useAuthStore, import.meta.hot))
}
info
If you're using auto-imports, there's no need to import useAuth.
Here are some resources to learn more about the previous example:
- Learn more about Auth Stores (useAuth)
useFeatherscomes from a composable utility patternuseUserStoreis a service store