Skip to content

How to wait for connection acknowledgement and then start subscription. #329

Open
@anirudhsharma392

Description

@anirudhsharma392
Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: GraphQLProvider(
        client: client,
        child: Subscription(operationName, subscription, builder: ({
          bool loading,
          dynamic payload,
          dynamic error,
        }) {
          if (loading==true) {
        return LoadingAnimation();
           
          }
    
          print("Subscription payload:  $payload");

          return Query(
              options: QueryOptions(
                document: playDuel,
                variables: {},
                pollInterval: 10000,
              ),
              builder: (QueryResult result, {VoidCallback refetch}) {
                if (result.errors != null) {
                  print(result.errors);
                }

                if (result.loading) {
                  return LoadingAnimation();
                }

                print(result.data['playDuel']);

                return Container();
              });
        }),
      ),
    );
  }

this loading function do not gives me live update about the connection.
it always returns true.
So all i want is to get data printed by Subscription widget on console get stored in some variable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    linkRelates to link functionality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions