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

Async helper #157

Open
sunng87 opened this issue May 18, 2017 · 4 comments · May be fixed by #513
Open

Async helper #157

sunng87 opened this issue May 18, 2017 · 4 comments · May be fixed by #513

Comments

@sunng87
Copy link
Owner

sunng87 commented May 18, 2017

What if we want some asynchronous tasks in handler helpers? With current API you might be able to do that but there is no guarantee on the order of writes on template string buffer.

Perhaps we will need a future-rs based API for this task? Will it be in the core library or as an extension?

@sunng87 sunng87 linked a pull request Jul 1, 2022 that will close this issue
4 tasks
@lovasoa
Copy link
Contributor

lovasoa commented Sep 11, 2022

Support for asynchronous helpers would help me a lot in sqlpage

Currently I hand-roll my own template-splitting solution to be able to call rennder across await points, but this is less than ideal.

@backspace
Copy link

I’m quite new to Rust so I might be thinking about things incorrectly but this might be helpful for the application I’m working on for a voice response system; I’d love to have a helper that’s passed the name of a prompt that checks the database to see if it has a recording and uses a fallback string if not.

@sunng87
Copy link
Owner Author

sunng87 commented Apr 25, 2023

I found it's almost impossible to have both sync and async helper supported simultaneously because async function require that full invocation path to be async.

I will recommend you not to put your logic into helper. You'd better fetch all data required by the template and put them into the context. Helper are suitable for formatting, complex if/else check but not IO tasks.

@backspace
Copy link

👍🏻 that’s what I did end up with, thanks for the feedback 😀

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

Successfully merging a pull request may close this issue.

3 participants