Skip to content

Commit 3bc35ae

Browse files
Simplify docs around receiving an INodeServices instance from DI
1 parent 920f1c8 commit 3bc35ae

1 file changed

Lines changed: 3 additions & 21 deletions

File tree

  • src/Microsoft.AspNetCore.NodeServices

src/Microsoft.AspNetCore.NodeServices/README.md

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -63,30 +63,12 @@ public void ConfigureServices(IServiceCollection services)
6363
}
6464
```
6565

66-
Now you can receive an instance of `NodeServices` as a constructor parameter to any MVC controller, e.g.:
66+
Now you can receive an instance of `NodeServices` as an action method parameter to any MVC action, and then use it to make calls into Node.js code, e.g.:
6767

6868
```csharp
69-
using Microsoft.AspNetCore.NodeServices;
70-
71-
public class SomeController : Controller
72-
{
73-
private INodeServices _nodeServices;
74-
75-
public SomeController(INodeServices nodeServices)
76-
{
77-
_nodeServices = nodeServices;
78-
}
79-
80-
// ... your action methods are here ...
81-
}
82-
```
83-
84-
Then you can use this instance to make calls into Node.js code, e.g.:
85-
86-
```csharp
87-
public async Task<IActionResult> MyAction()
69+
public async Task<IActionResult> MyAction([FromServices] INodeServices nodeServices)
8870
{
89-
var result = await _nodeServices.InvokeAsync<int>("./addNumbers", 1, 2);
71+
var result = await nodeServices.InvokeAsync<int>("./addNumbers", 1, 2);
9072
return Content("1 + 2 = " + result);
9173
}
9274
```

0 commit comments

Comments
 (0)