diff --git a/README.md b/README.md index d14dab4..40086f1 100644 --- a/README.md +++ b/README.md @@ -214,6 +214,32 @@ export default { } ``` +#### `wrapLoading(loader String, func Function, [,force_sync = false])` + +Decorator that wraps function, +will trigger a loading and will end loader after the original function (`func` argument) is finished. + +By default `wrapLoading` return async function, +if you want to wrap default sync function pass `true` in last argument + +_Example using with async function_ + +```js +methods: { + fetchDataFromApi: wrapLoading('fetch data', async function () { + function sleep(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + } + // do work here + await sleep(3000); + // simulate some api call + this.fetchResponse = Math.random() + }) +} +``` + +See also `examples/wrap-example` + ## Using `v-loading` Component If you disable `registerComponents` option then @@ -230,7 +256,7 @@ In template, you should wrap your content with `v-loading` component to show loa ```html -