-
Notifications
You must be signed in to change notification settings - Fork 1.7k
cascading await #23000
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
Comments
Removed Type-Defect label. |
I don't see this syntax happening. I'd put my money on #25986 instead, introducing a suffix form of await, so you could write, e.g., testDriver..deleteAll().await
..createNew().await
..refresh().await; (or whatever syntax would be used for that). The problem with allowing prefix operators to be used infix is that it's not clear how they bind. So, probably won't happen as this. |
+1, just made a mistake today: final auth = await context.read<AuthStore>()..login(); this wouldn't work because I need to await final auth = context.read<AuthStore>();
await auth.login() The desirable syntax is |
how does that differ from normal if(await foo().bar()) // calls foo and awaits its bar
if((await foo()).bar()) // awaits foo and then calls its bar and we know that, no ambiguity.. if(foo().bar().await.baz()) would probably confuse people as dart does not use .await as a postfix normally but, tbh, on the other hand I already find final auth = await context.read<AuthStore>()..login(); somewhat ambigous already, as i thought cascading async calls would work similar to promise/future chaining à la var auth;
await asyncGet<AuthStore>().then(init).then(login).then((a)=>auth=a) which makes the whole call a future as soon as one part is async, and awaiting would await all calls and make final auth = await asyncGet<AuthStore>()..init()..login(); work as @subzero911 (and I, which brought me here in the first place) thought (intuitively without actually thinking about it) it would |
This issue was originally filed by [email protected]
Would it be possible to make the following work?
testDriver..await deleteAll()
..await createNew()
..await refresh();
The text was updated successfully, but these errors were encountered: