forked from zino-hofmann/graphql-flutter
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zino-hofmann#691 from artflutter/flutter-bloc5-exm…
…aple-update Updated `flutter_bloc` example to work with `flutter_bloc` lib v5
- Loading branch information
Showing
11 changed files
with
1,552 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 46 additions & 15 deletions
61
examples/flutter_bloc/lib/extended_bloc/graphql/event.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,63 @@ | ||
import 'package:freezed_annotation/freezed_annotation.dart'; | ||
import 'package:graphql/client.dart'; | ||
import 'package:meta/meta.dart'; | ||
|
||
part 'event.freezed.dart'; | ||
|
||
abstract class GraphqlEvent<T> {} | ||
|
||
class GraphqlErrorEvent<T> extends GraphqlEvent<T> { | ||
final OperationException error; | ||
final QueryResult result; | ||
@freezed | ||
abstract class GraphqlErrorEvent<T> extends GraphqlEvent<T> | ||
implements _$GraphqlErrorEvent<T> { | ||
GraphqlErrorEvent._(); | ||
|
||
factory GraphqlErrorEvent({ | ||
@required OperationException error, | ||
@required QueryResult result, | ||
}) = _GraphqlErrorEvent<T>; | ||
} | ||
|
||
@freezed | ||
abstract class GraphqlRunQueryEvent<T> extends GraphqlEvent<T> | ||
implements _$GraphqlRunQueryEvent<T> { | ||
GraphqlRunQueryEvent._(); | ||
|
||
GraphqlErrorEvent({@required this.error, @required this.result}); | ||
factory GraphqlRunQueryEvent() = _GraphqlRunQueryEvent<T>; | ||
} | ||
|
||
class GraphqlLoadingEvent<T> extends GraphqlEvent<T> { | ||
final QueryResult result; | ||
@freezed | ||
abstract class GraphqlLoadingEvent<T> extends GraphqlEvent<T> | ||
implements _$GraphqlLoadingEvent<T> { | ||
GraphqlLoadingEvent._(); | ||
|
||
GraphqlLoadingEvent({@required this.result}); | ||
factory GraphqlLoadingEvent({ | ||
@required QueryResult result, | ||
}) = _GraphqlLoadingEvent<T>; | ||
} | ||
|
||
class GraphqlLoadedEvent<T> extends GraphqlEvent<T> { | ||
final T data; | ||
final QueryResult result; | ||
@freezed | ||
abstract class GraphqlLoadedEvent<T> extends GraphqlEvent<T> | ||
implements _$GraphqlLoadedEvent<T> { | ||
GraphqlLoadedEvent._(); | ||
|
||
GraphqlLoadedEvent({@required this.data, @required this.result}); | ||
factory GraphqlLoadedEvent({@required T data, @required QueryResult result}) = | ||
_GraphqlLoadedEvent<T>; | ||
} | ||
|
||
class GraphqlRefetchEvent<T> extends GraphqlEvent<T> {} | ||
@freezed | ||
abstract class GraphqlRefetchEvent<T> extends GraphqlEvent<T> | ||
implements _$GraphqlRefetchEvent<T> { | ||
GraphqlRefetchEvent._(); | ||
|
||
factory GraphqlRefetchEvent() = _GraphqlRefetchEvent<T>; | ||
} | ||
|
||
class GraphqlFetchMoreEvent<T> extends GraphqlEvent<T> { | ||
final FetchMoreOptions options; | ||
@freezed | ||
abstract class GraphqlFetchMoreEvent<T> extends GraphqlEvent<T> | ||
implements _$GraphqlFetchMoreEvent<T> { | ||
GraphqlFetchMoreEvent._(); | ||
|
||
GraphqlFetchMoreEvent({@required this.options}); | ||
factory GraphqlFetchMoreEvent({ | ||
@required FetchMoreOptions options, | ||
}) = _GraphqlFetchMoreEvent<T>; | ||
} |
Oops, something went wrong.