@gsox/client

subscription client for consuming webhook data

Stats

StarsIssuesVersionUpdatedCreatedSize
@gsox/client
0.3.03 years ago3 years agoMinified + gzip package size for @gsox/client in KB

Readme

gsox-client

subscription client for consuming webhook data

Installation

npm i @gsox/client

React

import { createClient, StreamProvider, StreamConsumer } from "@gsox/client"

const client = createClient({ host, port, inject })

<StreamProvider client={client}>
      <StreamConsumer types={[Notification]}>

      {({ data, error, loading }) => {
            if(loading) return <Loading />
            if(data) return <DataView />
      }}

      </StreamConsumer>
</StreamProvider>

Observable

import { createClient } from "@gsox/client"

const client = createClient({ host, port, inject })

client.subscribe([Notification, Alert], {
      next: data => console.log(data),
      error: error => console.log(error)
})

Subscribe with GraphQL DocumentNode

import gql from "graphql-tag";

const query = gql`
  subscription {
    Alert {
      id
      timestamp
    }
  }
`
client.subscribeWithQuery(query, {
      next: data => console.log(data),
      error: error => console.log(error)
});

Options

{
  host: "localhost",
  port: 3000,
  routes: {
    graphql: "/graphql"
  },
  inject: [...types]
}

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.