![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@oarepo/invenio-api-vue-composition
Advanced tools
## Run demo ``` docker-compose -f docker-compose-server.yml up yarn serve ``` ## Installation
docker-compose -f docker-compose-server.yml up
yarn serve
yarn add @vue/composition-api
yarn add @oarepo/vue-query-synchronizer
yarn add @oarepo/invenio-api-vue-composition
// main.js
Vue.use(VueCompositionAPI)
Vue.use(VueQuerySynchronizer, {
debug: true,
router: router
})
Wrap your components when you add them into routes:
export const routes = [
// note: record needs to be the first because of its path
record({
name: 'record-viewer-editor',
// path is implicitely '/${collectionCode}' -we want the records in the root, so have to create it manually
path: '/:recordId',
collectionCode: 'records',
component: RecordViewer
}),
collection({
name: 'record-list',
path: '/',
collectionCode: 'records',
component: CollectionViewer,
recordRouteName: 'record-viewer'
})
]
This will inject a wrapper component (invisible in DOM tree) that fetches the collection/record, shows the loading status and possible errors, on success pass records and facets to your component and reacts to facet selection, pagination and search as emitted by your component.
A sample implementation of CollectionViewer is in the demo.
Facet shows that each facet contains a reactive model that can be used to directly toggle the facet on/off.
For a record viewer see RecordViewer
See the collection API docs and record API docs for possible parameters and for an extensive list of properties that are passed to your component.
You can have an access to API either via the wrappers above - but they always fetch the data before your component gets called - or via the "api" wrappers:
export const routes = [
collectionApi({
name: 'record-creator',
path: '/create',
collectionCode: 'records',
component: RecordCreator
}),
]
This wrapper just creates the API, pre-populates it with the baseUrl and collection code and passes control (with all props) to your component.
It is usable for example, for creating new records as shown above, as there is no need to load the collection when a new record is created within it.
See collection API docs for details
The collectionApi
or recordApi
props passed to your component are return values of
Composable API functions useInvenioCollection
and useInvenioRecord
.
If you want you can use them directly without the wrapper components (
but always directly in the setup
function, you can not initialize them later, as in event handlers):
<template>...</template>
<script>
import {useInvenioCollection} from '@oarepo/invenio-api-vue-composition'
export default {
function setup(props, ctx) {
{
error,
facets,
records,
load
// see the docs for other options here
} = useInvenioCollection('/api')
load('records')
return {
error, facets, records
}
}
}
</script>
More documentation is at API docs
FAQs
## Run demo ``` docker-compose -f docker-compose-server.yml up yarn serve ``` ## Installation
The npm package @oarepo/invenio-api-vue-composition receives a total of 1 weekly downloads. As such, @oarepo/invenio-api-vue-composition popularity was classified as not popular.
We found that @oarepo/invenio-api-vue-composition demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.