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.

The ask here is:

  • suspend accepts a first parameter that is an AbortSignal.
  • when the component is unmounted - abort the controller associated with the signal.

e.g.

function Post({ id, version }) {
  const data = suspend(async ({ signal }) => {
    const res = await fetch(`https://hacker-news.firebaseio.com/${version}/item/${id}.json`, { signal })
    return await res.json()
  }, [id, version])
  return (
    <div>
      {data.title} by {data.by}
    </div>
  )
}

Basically allowing aborting expensive async actions.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
drcmdacommented, Feb 16, 2022

im glad you asked, because there aren’t any. by all means … add some 😄

1reaction
drcmdacommented, Feb 16, 2022

about the call signature, maybe:

async function fn([a, b, c], { signal }) {
  ...
}

useSuspend(fn, [a, b, c])

so keys come out as they go in (as an array, no spread), second arg is an extensible object that could later be built out.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cancellation Definition & Meaning - Merriam-Webster
1 · the act or an instance of canceling. The cancellation of the game was due to bad weather. ; 2 · something...
Read more >
Cancellation Definition & Meaning - Dictionary.com
something canceled, as a reservation for a hotel room, airplane ticket, allowing someone else to obtain the accommodation.
Read more >
cancellation - Wiktionary
NounEdit · The act, process, or result of cancelling; as, the cancellation of certain words in a contract, or of the contract itself....
Read more >
CANCELLATION definition | Cambridge English Dictionary
the act of deciding that an organized event will not happen or of stopping an order for something: Many trains are subject to...
Read more >
37 Synonyms & Antonyms for CANCELLATION - Thesaurus.com
Find 37 ways to say CANCELLATION, along with antonyms, related words, and example sentences at Thesaurus.com, the world's most trusted free thesaurus.
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