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.

Access non-decorated function

See original GitHub issue

First of all, thanks for this sweet library!

I start using it and I don’t get one thing. I have the following:

 makeAwsomeString(): string {
}
  @Action({ rawError: true })
  async doSomething(data: { email: string }) {
    this.makeAwsomeString() /// this causes an error 
  }

When I call makeAwsomeString from an Action I’m getting:

error in v-on handler (promise/async): "typeerror: makeAwsomeString is not a function"

Whats the issue here and how can I solve it?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8

github_iconTop GitHub Comments

9reactions
nsorincommented, Feb 18, 2021

This is should be considered a bug, for two main reasons:

  • It makes it impossible to outsource instance logic in reusable methods unless one misuses the “Action” paradigm. Sometimes the called method needs access to this, for instance to call getters, without being an action. So the solution proposed by @fen89 has its limits.
  • It produces an unexpected behaviour that is very hard to debug. By TypeScript/JavaScript standards, @eikebartels 's makeAwsomeString method should be callable from doSomething. It is not obvious at all when looking at the code that such a thing is not possible.

Stripping code from the original class seems like a terrible idea that can only cause headaches to the users. At the very least, private methods should be kept, since their very purpose is to be called by other methods.

0reactions
msmsimondeancommented, Mar 10, 2021

I’m not sure the work around works when you want to call non-decorated private functions from a mutation rather than from an action. I’ve got some helper functions that need to be able to both get and set state and I can’t call them from my mutation

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to strip decorators from a function in Python
This is untrue. The decorated function only has a __wrapped__ attribute if you decorate it with functools.wraps . Also, the link is dead....
Read more >
Primer on Python Decorators
The @register decorator simply stores a reference to the decorated function in the global PLUGINS dict. Note that you do not have to...
Read more >
Function Decorators — wrapt 1.13.0rc2 documentation
Supplying a boolean value for the enabled option when defining a decorator provides control over whether the decorator should be applied or not....
Read more >
How to Create and Use Decorators in Python With Examples
Accessing the function from the variable I assigned it to. ... To create a decorator function in Python, I create an outer function...
Read more >
Decorators with parameters in Python - GeeksforGeeks
Now, func_name() can be used to call the function with decorator applied on ... parameters can be accessed by the enclosed inner function....
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