{"id":15764645,"url":"https://github.com/ctf0/vue-async-helper","last_synced_at":"2025-03-31T10:21:55.668Z","repository":{"id":57394516,"uuid":"145586165","full_name":"ctf0/vue-async-helper","owner":"ctf0","description":"https://forum.vuejs.org/t/global-config-for-async-components/40980","archived":false,"fork":false,"pushed_at":"2023-01-03T23:05:14.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-11T12:18:10.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ctf0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"ctf0"}},"created_at":"2018-08-21T15:49:52.000Z","updated_at":"2023-01-03T23:05:19.000Z","dependencies_parsed_at":"2023-02-01T12:31:32.871Z","dependency_job_id":null,"html_url":"https://github.com/ctf0/vue-async-helper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Fvue-async-helper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Fvue-async-helper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Fvue-async-helper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ctf0%2Fvue-async-helper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ctf0","download_url":"https://codeload.github.com/ctf0/vue-async-helper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246450678,"owners_count":20779460,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-04T12:04:19.130Z","updated_at":"2025-03-31T10:21:55.651Z","avatar_url":"https://github.com/ctf0.png","language":"JavaScript","funding_links":["https://github.com/sponsors/ctf0"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n    Vue Async Helper\n    \u003cbr\u003e\n    \u003ca href=\"https://www.npmjs.com/package/vue-async-helper\"\u003e\u003cimg src=\"https://img.shields.io/npm/v/vue-async-helper.svg?style=for-the-badge\" alt=\"npm\" /\u003e\u003c/a\u003e \u003ca href=\"https://www.npmjs.com/package/vue-async-helper\"\u003e\u003cimg src=\"https://img.shields.io/npm/dt/vue-async-helper.svg?style=for-the-badge\" alt=\"npm\" /\u003e\u003c/a\u003e\n\u003c/h1\u003e\n\n- based on : https://vuejs.org/v2/guide/components-dynamic-async.html#Handling-Loading-State\n- original post : https://forum.vuejs.org/t/global-config-for-async-components/40980\n\nBig thanx to [@LinusBorg](https://github.com/LinusBorg).\n\n## Installation\n\n```bash\nnpm install vue-async-helper --save\n```\n\n## Usage\n\n- assign the function to the `window` so you can use it everywhere without re-importing\n\n    ```js\n    import VAC from 'vue-async-helper'\n    window.VueAsyncComponent = VAC\n    ```\n\n- now replace the `() =\u003e import(...)` call with `VueAsyncComponent(import(...))`\n\n    ```js\n    /* global */\n    Vue.component('MyComp', () =\u003e import('abc.vue'))                // before\n    Vue.component('MyComp', VueAsyncComponent(import('abc.vue')))   // after\n\n    /* local */\n    components: {\n        MyComp: () =\u003e import('abc.vue')                // before\n        MyComp: VueAsyncComponent(import('abc.vue'))   // after\n    },\n    ```\n\n    |   prop  |                default                |                                       description                                       |\n    |---------|---------------------------------------|-----------------------------------------------------------------------------------------|\n    | loading | \"Please Stand By...\"                  | A component to use while the async component is loading                                 |\n    | error   | \"Something Went Wrong, Plz Try Again\" | A component to use if the load fails                                                    |\n    | delay   | 200                                   | Delay before showing the loading component **\"in ms\"**                                  |\n    | timeout | 5000                                  | The error component will be displayed if a timeout is provided and exceeded **\"in ms\"** |\n\n\u003cbr\u003e\n\n### Changing the helper defaults\n\n- you can change the default options per call like\n    ```js\n    Vue.component('MyComp', VueAsyncComponent(import('abc.vue'), {\n        timeout: 1000\n    }))\n    ```\n\n- or globally\n    - first create a new file\n        ```js\n        // vac.js\n        import VAC from 'vue-async-helper'\n        window.VueAsyncComponent = (item) =\u003e {\n            return VAC(item, {\n                loading: LoadingComp,\n                error: ErrorComp,\n                delay: 500,\n                timeout: 2000\n            })\n        }\n        ```\n\n    - next require that file and follow the usage as normal\n        ```js\n        // app.js\n        require('vac.js')\n\n        Vue.component('MyComp', VueAsyncComponent(import('abc.vue')))\n        ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctf0%2Fvue-async-helper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fctf0%2Fvue-async-helper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fctf0%2Fvue-async-helper/lists"}