TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Flutter: Futures, Isolates, Event Loop

193 pointsby yannikyeoover 6 years ago

8 comments

matt2000over 6 years ago
This is a great writeup, wish I had it when I started with Flutter. BTW, I&#x27;ve written a couple Flutter apps now and this set of tools (Futures, async&#x2F;await, Isolates) covers my multithreading use cases in a really nice and safe way.<p>By comparison, Grand central dispatch is pretty nice on iOS, but I really miss the first class async&#x2F;await calls. Side note: How did they make an entirely new language for app development (Swift) and not build in async&#x2F;await support?<p>Kotlin co-routines seem to be a pretty nice solution on Android, but before that it was a bit of a mess. There was 4 or 5 different ways to do things async, they all interact in super complicated ways with the activity life cycle, and basically nothing is quite what you need.<p>Side side note: Unity also does a really nice version of all of this with a single event loop and really powerful co-routines. Worth checking out sometime.
评论 #18967248 未加载
评论 #18966932 未加载
评论 #18967383 未加载
评论 #18966559 未加载
评论 #18966248 未加载
pestsover 6 years ago
I&#x27;ve been getting into Flutter and Dart recently after being a long time React fan. I must say I like many things Flutter does differently. Especially around its Material UI package (built-in) which is miles above any other web material component library in any framework (React, Vue, Angular, etc.)<p>I must say wrapping my head around the addition of &#x27;await&#x27; and the changes it made to the EventLoop processing was difficult but as I type this comment I realize I do fully grok it now. I must say that this is IMO probably the most important piece of info in the article.<p>Basically,<p>&quot;`await` causes immediate execution of the Future (up to the first `await` in the Future) verses appending the Future to the end of the EventLoop queue&quot;<p>If I have the above wrong someone please call me out.<p>Great article.
评论 #18966710 未加载
zdragnarover 6 years ago
I&#x27;m no functional fanatic, but one thing that I enjoy about it is the idea that function calls- and futures- resolve to a value.<p>The code example where D doesn&#x27;t get called last because of the missing await grinds my gears something fierce, especially because I missed it the first glance through. This type of bug is much harder to create when you don&#x27;t constantly rely on side effects everywhere.<p>That said, the article did a really good job if you&#x27;re not already familiar with the same concepts from JS land (with the event loop sans visible microtasks, Promise instead of Future, abd web worker instead of Isolate).
评论 #18967463 未加载
vmspover 6 years ago
If you&#x27;re interested in the Dart VM, I also recommend taking a look at Vyacheslav Egorov&#x27;s Introduction to Dart VM (<a href="https:&#x2F;&#x2F;mrale.ph&#x2F;dartvm&#x2F;" rel="nofollow">https:&#x2F;&#x2F;mrale.ph&#x2F;dartvm&#x2F;</a>).
ridiculous_fishover 6 years ago
What is the role of the `async` keyword in Dart? I couldn&#x27;t understand it from the article.<p>&gt; the outcome of the method is a Future<p>Isn&#x27;t the function signature sufficient to express this?<p>&gt; it runs synchronously the code of that method up to the very first await keyword<p>How is this different from non-async methods?<p>&gt; the next line of code will be run as soon as the Future, referenced by the await keyword, will have completed<p>But the await keyword is in the caller which is not statically known.<p>What is the difference between an async method and a method that returns a Future?
评论 #18966852 未加载
评论 #18966845 未加载
评论 #18966848 未加载
huhtenbergover 6 years ago
A typo:<p><pre><code> while (microTaskQueue.isNotEmpty){ ... return; } </code></pre> It should be either &quot;if { ... return }&quot; or just &quot;while { ... }&quot;.
ymannnover 6 years ago
Wow, I have no idea how similar Dart is to JavaScript.<p>Isolate == Worker Future == Promise
评论 #18968018 未加载
kamuraover 6 years ago
For someone used to work with async&#x2F;await only in C#, I was not expecting the execution model to be so fundamentally different in Dart.<p>Something to try to wrap my head around later!