npm package: @owaf/absinthe-socket-relay
Description: Absinthe Socket Relay
Author: Mauro Titimoli
Latest version: 10.0.1

# @owaf/absinthe-socket-relay

> Absinthe Socket Relay

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
<!-- END doctoc -->

- [Installation](#installation)
  - [Using npm](#using-npm)
  - [Using yarn](#using-yarn)
- [Examples](#examples)
- [API](#api)
  - [createFetcher](#createfetcher)
    - [Parameters](#parameters)
  - [createSubscriber](#createsubscriber)
    - [Parameters](#parameters-1)
  - [isSubscribed](#issubscribed)
    - [Parameters](#parameters-2)
- [References](#references)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->

## Installation

### Using [npm](https://docs.npmjs.com/cli/npm)

    $ npm install --save @owaf/absinthe-socket-relay

### Using [yarn](https://yarnpkg.com)

    $ yarn add @owaf/absinthe-socket-relay

## Examples

-   **relay-environment.js**

```javascript
// @flow

import {createFetcher, createSubscriber} from "@absinthe-phoenix-socket-relay";
import {Environment, Network} from "relay-runtime";

import absintheSocket from "./absintheSocket";

export default new Environment({
  network: Network.create(
    createFetcher(absintheSocket),
    createSubscriber(absintheSocket)
  ),
  store: new Store(new RecordSource())
});
```

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### createFetcher

Creates a Fetcher (Relay FetchFunction) using the given AbsintheSocket
instance

#### Parameters

-   `absintheSocket` **AbsintheSocket** 
-   `onError` **function (error: [Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)): any** 

Returns **FetchFunction** 

### createSubscriber

Creates a Subscriber (Relay SubscribeFunction) using the given AbsintheSocket
instance

#### Parameters

-   `absintheSocket` **AbsintheSocket** 
-   `onRecoverableError` **function (error: [Error](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Error)): any** 

Returns **SubscribeFunction** 

### isSubscribed

Returns a promise that resolves to `true` in case subscription of given
disposable has started or to `false` otherwise

#### Parameters

-   `disposable` **Disposable** 

Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)&lt;[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>** 

## References

-   [Absinthe Socket](https://github.com/absinthe-graphql/absinthe-socket/tree/master/packages/socket)
-   **Relay**
    -   [Environment](https://facebook.github.io/relay/docs/relay-environment.html)
    -   [NetworkLayer](https://facebook.github.io/relay/docs/network-layer.html)
    -   [FetchFunction](https://github.com/facebook/relay/blob/master/packages/relay-runtime/network/RelayNetworkTypes.js#L79)
    -   [SubscribeFunction](https://github.com/facebook/relay/blob/master/packages/relay-runtime/network/RelayNetworkTypes.js#L93)

## License

[MIT](LICENSE.txt) :copyright: Jumpn Limited.