question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Action event on loaded component Async

See original GitHub issue

What problem does this feature solve?

Reference: https://vuejs.org/v2/guide/components-dynamic-async.html#Handling-Loading-State

Current Issue: We do not know when the async component was loaded, with this, the ‘Ref’ is also not recognized in the ‘mounted()’ father

What does the proposed API look like?

Feature Request: Prop from ‘created’ in asynchronous component to go event

const AsyncComponent = () => ({
  // The component to load (should be a Promise)
  component: import('./MyComponent.vue'),
  // A component to use while the async component is loading
  loading: LoadingComponent,
  // A component to use if the load fails
  error: ErrorComponent,
  // Delay before showing the loading component. Default: 200ms.
  delay: 200,
  // The error component will be displayed if a timeout is
  // provided and exceeded. Default: Infinity.
  timeout: 3000,
  created: () => something()
})

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

11reactions
akccakcctwcommented, Dec 9, 2020

I found a cleaner way to do this (without modify child component):

<ChildAsync @hook:mounted="doSomething"/>
3reactions
yyx990803commented, Feb 4, 2019

You can add a listener on the child component:

<ChildAsync @ready="doSomething"/>

Then in the child’s mounted hook do this.$emit('ready')

Read more comments on GitHub >

github_iconTop Results From Across the Web

How To Handle Async Data Loading, Lazy Loading, and Code ...
In this step, you asynchronously loaded components. You used lazy and Suspense to dynamically import components and to show a loading message ...
Read more >
Set loading state before and after an action in a React class ...
8. I took it a step further and did const asyncSetState = instance => newState => new Promise(resolve => instance.setState(newState, resolve)); which you...
Read more >
Components With Async Friendly Event Handlers - Vatsal's Blog
These actions can be asynchronous in nature and it's in these cases where having async event handlers is quite beneficial.
Read more >
Redux Fundamentals, Part 6: Async Logic and Data Fetching
Just like with a normal action, we first need to handle a user event in the application, such as a click on a...
Read more >
Performing Async Actions using Hooks | by Gasim Gasimzada
We should set up interface/contract that all parts of the abstracted idea agree upon. Using hooks to build async action functionality. Hooks ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found