Load stocks data off the network
Instead of hard-coding the stock data in the Dart file, this CL moves the data to a JSON file and loads that file over the network. This change improves load time for the Stocks app from 3 seconds to 2 seconds. Also, this CL removes shake-to-reload from the Stocks app because that also slows down load time (due to the two module systems fighting each other). R=rafaelw@chromium.org, ojan@chromium.org Review URL: https://codereview.chromium.org/1021723005
This commit is contained in:
parent
03a2006046
commit
cc1c9cb9fc
@ -33,14 +33,18 @@ class StocksApp extends App {
|
|||||||
${typography.white.title};'''
|
${typography.white.title};'''
|
||||||
);
|
);
|
||||||
|
|
||||||
List<Stock> _sortedStocks;
|
List<Stock> _sortedStocks = [];
|
||||||
bool _isSearching = false;
|
bool _isSearching = false;
|
||||||
bool _isShowingMenu = false;
|
bool _isShowingMenu = false;
|
||||||
String _searchQuery;
|
String _searchQuery;
|
||||||
|
|
||||||
StocksApp() : super() {
|
StocksApp() : super() {
|
||||||
_sortedStocks = oracle.stocks;
|
fetchStockOracle().then((oracle) {
|
||||||
_sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol));
|
setState(() {
|
||||||
|
_sortedStocks = oracle.stocks;
|
||||||
|
_sortedStocks.sort((a, b) => a.symbol.compareTo(b.symbol));
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleSearchClick(_) {
|
void _handleSearchClick(_) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
2965
examples/stocks-fn/lib/stock_data.json
Normal file
2965
examples/stocks-fn/lib/stock_data.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,7 +5,6 @@
|
|||||||
// found in the LICENSE file.
|
// found in the LICENSE file.
|
||||||
-->
|
-->
|
||||||
<sky>
|
<sky>
|
||||||
<import src="/sky/framework/debug/shake-to-reload.sky" />
|
|
||||||
<script>
|
<script>
|
||||||
// TODO(abarth): Should this be package:stocks/stocks_app.dart?
|
// TODO(abarth): Should this be package:stocks/stocks_app.dart?
|
||||||
import 'lib/stock_app.dart';
|
import 'lib/stock_app.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user