vue-api-platform
How to install:
npm i -s vue-api-platform
Use in your project
Vue
Use in a component
{ return user_: null } props: 'user' api: { return thisuser } { // An error occurs during the binding }
With parameters
{ return users_: null pages: 123 } props: 'users' api: users_: { return thisusers } { return thispages } { // An error occurs during the binding }
Functions
- $cacheDataApi set yourself ApiPlatform datas
- $refreshApi force refresh of a key or an URI
mixins: methods: { this } { this }
Use with the mixin with props
mixins: //Is the same than this { return user_: null } props: user: required: true api: { return thisuser }
The mixin have got many parameters:
- expose (false) : create a mixin named like the property passed (only works with computed)
- collection (false) : set the data is an URI of a collection, so the return datas are in an array
- array (false) : set that the query is an array, so the return datas are in an array
- required (true) : set the props required or not
- pages: list of pages (only works with collection)
With parameters
{ return itemUrl: null } mixins: //Is the same than this { return itemUrl: null item_: null } api: { return thisitemUrl } computed: { return thisitem_ }
Other utils mixin
isLoading
Create a computed apiIsLoading
which return a boolean if the there's a resource which is actually downloading
mixins: apiIsLoading
loadingRate
Create a computed apiLoadingRate
which return a percent that correspond to the number of variable which are actually downloading (0 => nothing downloaded, 100 => everything is downloaded)
mixins: apiLoadingRate
Debouncing queries
You can enable debounce for queries at a global level, or mixin level. The query will be executed once immediately the first time, afterwards it won't be executed again if it's called before its debounceTimeout
is expired. This is useful if you need to fire a query according to a text input change for example.
By default, debouncing is disabled for all queries.
use at global level
Vue
use at mixin level
mixin: