Skip to content

A plugin abstract subscribe to AppSync subscription topics.

License

Notifications You must be signed in to change notification settings

mhd999/appsync-subscription

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Flutter AppSync subscription Plugin

pub package

This plugin for Flutter handles subscripe to AWS AppSync subscription.

Getting Started

Add this to your package's pubspec.yaml file:

dependencies:
  appsync_subscription: ^1.0.1

Usage

Import the package with

import 'package:appsync_subscription/appsync_subscription.dart';
final endPoint = "https://yourappsync.appsync-api.region.amazonaws.com/graphql";
final apiKey = "your-api-key";
final port = 443;

class _MyHomePageState extends State<MyHomePage> {
  final _appsyncSubscription = new Subscription(endPoint, apiKey, port);

 @override
  Widget build(BuildContext context) {
    final query = {
      'query': '''subscription {
          onPublishResult(id: "12345") {
            id
          }
        }
        '''
    };
    _appsyncSubscription.subscripeToSubscription(query, _callBackFunc);
  }
    void _callBackFunc(data) {
    print('Data received from subscription $data');
    // update widget with new data
    setState(() {
    });
  }
}

About

A plugin abstract subscribe to AppSync subscription topics.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages