@absinthe/socket-relay 中文文档教程
@absinthe/socket-relay
Absinthe Socket Relay
- Installation
- Using npm
- Using yarn
- Examples
- API
- createFetcher
- createSubscriber
- isSubscribed
- References
- License
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
使用给定的 AbsintheSocket 创建一个 Fetcher (Relay FetchFunction) instance
Parameters
absintheSocket
AbsintheSocketonError
function (error: Error): any
返回 FetchFunction
createSubscriber
使用给定的 AbsintheSocket 创建订阅者 (Relay SubscribeFunction) instance
Parameters
absintheSocket
AbsintheSocketonRecoverableError
function (error: Error): any
返回 SubscribeFunction
isSubscribed
如果订阅给定,则返回解析为 true
的承诺 disposable 已启动或为 false
否则
Parameters
disposable
Disposable
References
License
麻省理工学院:版权所有:Jumpn Limited。
@absinthe/socket-relay
Absinthe Socket Relay
- Installation
- Using npm
- Using yarn
- Examples
- API
- createFetcher
- createSubscriber
- isSubscribed
- References
- License
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 instance
Parameters
absintheSocket
AbsintheSocketonError
function (error: Error): any
Returns FetchFunction
createSubscriber
Creates a Subscriber (Relay SubscribeFunction) using the given AbsintheSocket instance
Parameters
absintheSocket
AbsintheSocketonRecoverableError
function (error: 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
References
License
MIT :copyright: Jumpn Limited.