Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
1c292d68
Commit
1c292d68
authored
Jan 14, 2016
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1241 from abarth/stock_data
Switch back to GitHub hosting of stock data
parents
2508d34d
174164bc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
16 deletions
+4
-16
stock_data.dart
examples/stocks/lib/stock_data.dart
+4
-16
No files found.
examples/stocks/lib/stock_data.dart
View file @
1c292d68
...
@@ -53,20 +53,10 @@ class StockData {
...
@@ -53,20 +53,10 @@ class StockData {
}
}
typedef
void
StockDataCallback
(
StockData
data
);
typedef
void
StockDataCallback
(
StockData
data
);
const
_kChunk
Size
=
10
0
;
const
_kChunk
Count
=
3
0
;
String
_urlToFetch
(
int
chunk
)
{
String
_urlToFetch
(
int
chunk
)
{
Map
<
String
,
String
>
queryParameters
=
{
return
'https://domokit.github.io/examples/stocks/data/stock_data_
$chunk
.json'
;
'limitToFirst'
:
_kChunkSize
.
toString
(),
'startAt'
:
'
\"
${chunk * _kChunkSize}
\"
'
,
'orderBy'
:
'"
\
$key
"'
,
};
// Just a demo firebase app owned by eseidel.
return
new
Uri
.
https
(
'sizzling-torch-6112.firebaseio.com'
,
'.json'
,
queryParameters
=
queryParameters
).
toString
();
}
}
class
StockDataFetcher
{
class
StockDataFetcher
{
...
@@ -82,7 +72,6 @@ class StockDataFetcher {
...
@@ -82,7 +72,6 @@ class StockDataFetcher {
void
_fetchNextChunk
()
{
void
_fetchNextChunk
()
{
if
(!
actuallyFetchData
)
if
(!
actuallyFetchData
)
return
;
return
;
http
.
get
(
_urlToFetch
(
_nextChunk
++)).
then
((
http
.
Response
response
)
{
http
.
get
(
_urlToFetch
(
_nextChunk
++)).
then
((
http
.
Response
response
)
{
String
json
=
response
.
body
;
String
json
=
response
.
body
;
if
(
json
==
null
)
{
if
(
json
==
null
)
{
...
@@ -90,9 +79,8 @@ class StockDataFetcher {
...
@@ -90,9 +79,8 @@ class StockDataFetcher {
return
;
return
;
}
}
JsonDecoder
decoder
=
new
JsonDecoder
();
JsonDecoder
decoder
=
new
JsonDecoder
();
Map
responseJson
=
decoder
.
convert
(
json
);
callback
(
new
StockData
(
decoder
.
convert
(
json
)));
callback
(
new
StockData
(
responseJson
.
values
.
toList
()));
if
(
_nextChunk
<
_kChunkCount
)
if
(
responseJson
.
isNotEmpty
)
_fetchNextChunk
();
_fetchNextChunk
();
});
});
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment