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.

feat: add helper to wrap a function in a task

See original GitHub issue

Would you be interested in a helper that, accepting a function, returns an action that wraps that function? This is a pattern that’s come up in the application I maintain at work, where a component yields an async function.

I’m imagining something like this:

<SomeComponentThatYieldsAnAction as |someAction|>
  {{#let (action-to-task someAction) as |someTask|}}
    <button {{action (perform someTask)}}>
      {{if someTask.isRunning 'Running!' 'No running!'}}
    </button>
  {{/let}}
</SomeComponentThatYieldsAnAction>

If that’s of interest, I’m happy to PR an implementation!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
alexlafrosciacommented, Oct 11, 2019

Yeah, I don’t see it being too different than the lifecycle with regard to a component.

Maybe this would be worth prototyping as a separate add-on (or permanently being something separate) to work out mechanics before potentially upstreaming to this package.

0reactions
alexlafrosciacommented, Oct 13, 2019

I actually ended up able to support the task modifiers without separate helpers for each of them:

{{wrap-in-task (action this.someAction) type="drop" maxConcurrency=3}}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Correctly Wrap a JavaScript Function - TrackJS
Wrapping JavaScript functions lets you add common logic to functions you do not control, like native and external functions. Many JavaScript libraries ...
Read more >
How to use an object of a wrapped class as an argument in a ...
1) It should be Helper.PyMyFunction(mySettings) in run.py. 2) It should be def instead of cdef in front of PyMyFunction because I definitely ...
Read more >
Add wrapper functions for validation helper without Diagnostics
What we tried to do in our plugin was create function that wraps existing validation helpers and returns diag.Diagnostics instead of errors.
Read more >
Python | functools.wraps() function - GeeksforGeeks
wraps () is a decorator that is applied to the wrapper function of a decorator. It updates the wrapper function to look like...
Read more >
Async IO in Python: A Complete Walkthrough
Other Top-Level asyncio Functions; The Precedence of await. Conclusion; Resources. Python Version Specifics; Articles; Related PEPs; Libraries That Work ...
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