Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functional async #9

Open
dzmitry-lahoda opened this issue Apr 11, 2020 · 1 comment
Open

Functional async #9

dzmitry-lahoda opened this issue Apr 11, 2020 · 1 comment

Comments

@dzmitry-lahoda
Copy link

dzmitry-lahoda commented Apr 11, 2020

What do you think about replacing things like:

  public async Task<IActionResult> Get() =>
            Ok(new { tags = await _tagsService.GetAllAsync() });

to (whatever works)

 // use injection to see direct dependencies in each method
  public Task<IActionResult> Get([FromServices]ITagsService service) =>
                    service
                       .GetAllAsync()
                       .Ok(tags => new { tags = tags});
           //       service
           //            .GetAllAsync()
           //            .Next(tags =>Ok(new { tags = tags}));

So to speak it is possible to avoid await keyword(and still be async) in most cases and use pipelining. Looks like F#.

@dnikolovv
Copy link
Owner

As much as I like this approach, I think it's just going too far. I was kind of trying to find the balance between the standard (already familiar to most) and functional way of doing things. Sadly(?), C# is not a functional language, so I think it's better we stick to the "basics" where there's no obvious benefit of doing it functionally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants