Dart in Action by Chris Buckett

Dart in Action by Chris Buckett

Author:Chris Buckett
Language: eng
Format: mobi, epub, pdf
Published: 0101-01-01T00:00:00+00:00


Note

Callbacks are a common pattern, and you should get used to reading code that uses callbacks, but they do have their drawbacks, as you’ll discover. In the next section, you’ll see how you can improve existing APIs that use callbacks by using the Future and Completer pair of values.

The basic callback code, which is still running in a synchronous fashion but without the delay, is shown in figure 9.6. This is a simplified version that outputs a single winning number to the browser console.

Figure 9.6. The lottery.dart file defines a getWinningNumber() function that takes a callback parameter. The app passes a callback to getWinningNumber(), which is called when a number is retrieved.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.