Closed dancetrain closed 6 months ago
I want to take it
Sure, it is your.
@ai Hi! I found how to implement this. But something tells me that this is not quite the correct way to add this code to onMount in preview.ts. Can you comment on this approach?
onMount($candidates, () => {
let page = router.get()
page.route === 'add' && setPreviewUrl(page.params.url!)
return $links.listen(() => {})
})
Looks normal in terms of API. But I don’t understand why we have $links.listen(() => {})
Also, if we use router
, we usually need to subscribe to it. Can you explain why we didn’t subscribe?
@ai I apologize, but this was due to my not understanding the code well enough; it was a piece of old code. I propose this version, in which I subscribe to the router and return the unsubscribe function:
onMount($candidates, () => {
let unsubscribeRouter = router.subscribe(page => {
if (page.route === 'add') {
setPreviewUrl(page.params.url!);
}
});
return () => {
unsubscribeRouter();
};
});
Fixed 506c628
Steps to reproduce:
Web page URL or social account handle
input field (example: https://soundcloud.com/redaxes/flawless-club-mix-feat-echo)