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.

Allow useTask to be used outside of setup

See original GitHub issue

This could be useful for testing.

It seems the only blocker for this is the usage of onUnmounted() which would cause an error if used outside of setup. It could be conditionally turned off so that useTask() can be used anywhere.

 const mockTask = useTask(function*() {
      return "success";
    }, { cancelOnUnmount: false });
  const wrapper = mount(SaveButton, {
    propsData: {
      task,
    },
  });

  task.perform();
  expect(wrapper.find("button")).toBeDisabled();
 });

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:2
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
MartinMalindacommented, Feb 18, 2022

@dschmidt Thanks for the reminder. I’ll try to check the testing workflows with cancelOnUnmount: false and update that docs page and then close this issue 👍

https://vue-concurrency.netlify.app/testing/

2reactions
MartinMalindacommented, Jul 30, 2021

@rudolfbyker no, it still stands on top of composition api. It’s just that just like ref and computed can be used outside of the setup function, so can tasks now

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use task sequence variables - Configuration Manager
Click Add Condition, and select Task Sequence Variable. In the Task Sequence Variable dialog box, specify the following settings: Variable: The ...
Read more >
Use Task with AsyncStream and avoid retain cycle
In our case we'll use it directly in the UIViewController, it's a good setup for the purpose of this example. First, let's setup...
Read more >
Amazon ECS task definitions
A task definition is required to run Docker containers in Amazon ECS. The following are some of the parameters that you can specify...
Read more >
Create and use task templates in Remote Desktop
You can save a task's settings as a template to reuse for future tasks. For example, if you always use certain copy options...
Read more >
Use task queues - HubSpot Knowledge Base
Learn how to set up your tasks so you can complete them back to back within HubSpot's interface. Task views show you the...
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