@absinthe/socket-relay
Absinthe Socket Relay
- Using npm - Using yarn - createFetcher
- [Parameters](#parameters)
- createSubscriber- [Parameters](#parameters-1)
- isSubscribed- [Parameters](#parameters-2)
Installation
Using npm
$ npm install --save @absinthe/socket-relay
Using yarn
$ yarn add @absinthe/socket-relay
Examples
- relay-environment.js
// @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
createFetcher
Creates a Fetcher (Relay FetchFunction) using the given AbsintheSocket instanceParameters
absintheSocket
AbsintheSocketonError
function (error: Error): any
Returns FetchFunction
createSubscriber
Creates a Subscriber (Relay SubscribeFunction) using the given AbsintheSocket instanceParameters
absintheSocket
AbsintheSocketonRecoverableError
function (error: Error): any
Returns SubscribeFunction
isSubscribed
Returns a promise that resolves totrue
in case subscription of given
disposable has started or to false
otherwiseParameters
disposable
Disposable
Returns Promise<boolean>
References
- Absinthe 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)