File tree Expand file tree Collapse file tree 4 files changed +39
-37
lines changed Expand file tree Collapse file tree 4 files changed +39
-37
lines changed Original file line number Diff line number Diff line change @@ -16,38 +16,39 @@ class CardRepositoryImpl implements CardRepository {
1616 CardRepositoryImpl (this ._authClient, this ._cardResponseToCard);
1717
1818 @override
19- Stream <BuiltList <Card >> getCards () async * {
20- final json = await _authClient.getJson (buildUrl ('/cards' )) as List ;
21- yield json
22- .map ((e ) => CardResponse . fromJson (e))
23- .map (_cardResponseToCard )
24- . toBuiltList ();
25- }
19+ Single <BuiltList <Card >> getCards () =>
20+ Single . fromCallable (() => _authClient.getJson (buildUrl ('/cards' )))
21+ . cast < List >()
22+ .map ((json ) => json
23+ .map ((e) => CardResponse . fromJson (e) )
24+ . map (_cardResponseToCard)
25+ . toBuiltList ());
2626
2727 @override
28- Stream <Card > removeCard (Card card) =>
29- Rx .fromCallable (() => _authClient.delete (buildUrl ('/cards/${card .id }' )))
30- .mapTo (card);
28+ Single <Card > removeCard (Card card) => Single .fromCallable (
29+ () => _authClient.delete (buildUrl ('/cards/${card .id }' )))
30+ .mapTo (card)
31+ .singleOrError ();
3132
3233 @override
33- Stream <Card > addCard ({
34+ Single <Card > addCard ({
3435 required String cardHolderName,
3536 required String number,
3637 required int cvc,
3738 required int expYear,
3839 required int expMonth,
39- }) async * {
40- final body = {
41- 'card_holder_name' : cardHolderName,
42- 'number ': number ,
43- 'cvc ': cvc. toString () ,
44- 'exp_month ': expMonth ,
45- 'exp_year ': expYear ,
46- };
47- final json = await _authClient. postJson (
48- buildUrl ( '/cards' ),
49- body : body ,
50- );
51- yield _cardResponseToCard ( CardResponse . fromJson (json) );
52- }
40+ }) =>
41+ Single . fromCallable (() {
42+ final body = {
43+ 'card_holder_name ': cardHolderName ,
44+ 'number ': number ,
45+ 'cvc ': cvc. toString () ,
46+ 'exp_month ': expMonth ,
47+ 'exp_year' : expYear,
48+ };
49+ return _authClient. postJson (
50+ buildUrl ( '/cards' ) ,
51+ body : body,
52+ );
53+ }). map ((json) => CardResponse . fromJson (json)). map (_cardResponseToCard);
5354}
Original file line number Diff line number Diff line change 11import 'package:built_collection/built_collection.dart' ;
2+ import 'package:rxdart_ext/rxdart_ext.dart' ;
23
34import '../model/card.dart' ;
45
56abstract class CardRepository {
6- Stream <BuiltList <Card >> getCards ();
7+ Single <BuiltList <Card >> getCards ();
78
8- Stream <Card > removeCard (Card card);
9+ Single <Card > removeCard (Card card);
910
10- Stream <Card > addCard ({
11+ Single <Card > addCard ({
1112 required String cardHolderName,
1213 required String number,
1314 required int cvc,
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ packages:
3535 name: async
3636 url: "https://pub.dartlang.org"
3737 source: hosted
38- version: "2.5.0 "
38+ version: "2.6.1 "
3939 boolean_selector:
4040 dependency: transitive
4141 description:
@@ -355,7 +355,7 @@ packages:
355355 name: flutter_bloc_pattern
356356 url: "https://pub.dartlang.org"
357357 source: hosted
358- version: "2.1.0 "
358+ version: "2.1.1 "
359359 flutter_blurhash:
360360 dependency: transitive
361361 description:
@@ -811,7 +811,7 @@ packages:
811811 name: rxdart_ext
812812 url: "https://pub.dartlang.org"
813813 source: hosted
814- version: "0.1.1-dev.0 "
814+ version: "0.1.1-dev.1 "
815815 shared_preferences:
816816 dependency: "direct main"
817817 description:
@@ -900,7 +900,7 @@ packages:
900900 name: source_span
901901 url: "https://pub.dartlang.org"
902902 source: hosted
903- version: "1.8.0 "
903+ version: "1.8.1 "
904904 sqflite:
905905 dependency: transitive
906906 description:
@@ -935,7 +935,7 @@ packages:
935935 name: stream_loader
936936 url: "https://pub.dartlang.org"
937937 source: hosted
938- version: "1.2.0 "
938+ version: "1.2.1 "
939939 stream_transform:
940940 dependency: transitive
941941 description:
@@ -970,7 +970,7 @@ packages:
970970 name: test_api
971971 url: "https://pub.dartlang.org"
972972 source: hosted
973- version: "0.2.19 "
973+ version: "0.3.0 "
974974 timezone:
975975 dependency: transitive
976976 description:
Original file line number Diff line number Diff line change @@ -67,10 +67,10 @@ dependencies:
6767 rx_shared_preferences : ^2.1.0
6868 disposebag : ^1.5.0
6969 flutter_disposebag : ^1.1.0
70- flutter_bloc_pattern : ^2.1.0
71- rxdart_ext : ^0.1.1-dev.0
70+ flutter_bloc_pattern : ^2.1.1
71+ rxdart_ext : ^0.1.1-dev.1
7272 listenable_stream : ^1.1.0
73- stream_loader : ^1.2.0
73+ stream_loader : ^1.2.1
7474 flutter_google_places_hoc081098 : ^1.0.0-nullsafety.2
7575 utils :
7676 path : ../utils
You can’t perform that action at this time.
0 commit comments