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.

async method named "get"

See original GitHub issue

When you name a async method get and try to decorate it, it will get called whenever it is referenced and not function as expected.

let decorator = target => {
    return target;
};

class Example {
	@decorator async get () {
		console.log('called');
	}
}

let instance = new Example();
typeof instance.get;

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
loganfsmythcommented, Mar 1, 2017

Oh you’re right about function in that case, that’s probably just an extreme edge case in the spec then.

If you wanted to replace the function, the easiest option would be to do

let decorator = (target, property, descriptor) => {
	descriptor.value = function() {
		// how can i set something on the target without returning the target?
	};
        return descriptor;
};
0reactions
icodeforlovecommented, Mar 1, 2017

Thanks, this is the best way to do it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get current method name from async function? - Stack Overflow
You need to capture the method name early in the async method, somewhere before the first async call. The most ...
Read more >
Task asynchronous programming model - Microsoft Learn
The method name ends in Async . In the body of the method, GetStringAsync returns a Task<string> . That means that when you...
Read more >
async function - JavaScript - MDN Web Docs - Mozilla
The async function declaration declares an async function where the await keyword is permitted within the function body. The async and await ...
Read more >
4. Writing Async Methods - Async in C# 5.0 [Book] - O'Reilly
An async method isn't automatically asynchronous. Async methods just make it easier to consume other asynchronous methods. They start running synchronously, ...
Read more >
Getting Started | Creating Asynchronous Methods - Spring
This class also customizes the Executor by defining a new bean. Here, the method is named taskExecutor , since this is the specific...
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