Summary

You now have a better understanding of event-driven architecture, which is one of the key concepts of Dart VM. Event-driven architecture is the right approach to build loosely coupled asynchronous systems.

Dart relies on event-driven architecture based on a single-threaded execution model with a single event loop and two queues. The event loop is backed by a single thread, so no synchronization or locks are required at all. When the event loop is blocked with an operation, this blocks the entire application. A combination of single-threaded execution models and asynchronous operations allows an application to be more productive and less resource intensive.

Future is a proxy for an initially unknown result that returns as a value instead of calling a callback function. Future almost always adds an event or microtask into the queue that is being processed in the event loop. Future can be completed with a value or error only once.

Zones implement the best practices of a configurable code wrapper to handle the uncaught errors. Zones can have local variables and can schedule microtasks, create one-off or repeating timers, print information, and save a stack trace for debugging purposes.

An isolate is a process built around the model of servicing simple messaging queue. It does not share the memory with other isolates and all isolates communicate by passing messages, which are copied before they are sent.

In the next chapter, we will see the stream framework and show when and how to properly use it.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.223.190