0.3.0 • Published 6 years ago

@gsox/client v0.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
6 years ago

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]
}
0.3.0

6 years ago

0.2.3

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.18

6 years ago

0.1.17

6 years ago

0.1.16

6 years ago

0.1.15

6 years ago

0.1.14

6 years ago

0.1.13

6 years ago

0.1.12

6 years ago

0.1.11

6 years ago

0.1.10

6 years ago

0.1.8

6 years ago

0.1.7

6 years ago

0.1.6

6 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.0

6 years ago