@activimetrics/socket-relay 中文文档教程

发布于 5年前 浏览 11 项目主页 更新于 3年前

@activimetrics/socket-relay

Absinthe Socket Relay

Installation

Using npm

$ npm install --save @activimetrics/socket-relay

Using yarn

$ yarn add @activimetrics/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 AbsintheSocket
  • onError function (error: Error): any

返回 FetchFunction

createSubscriber

使用给定的 AbsintheSocket 创建订阅者 (Relay SubscribeFunction) instance

Parameters

  • absintheSocket AbsintheSocket
  • onRecoverableError function (error: Error): any

返回 SubscribeFunction

isSubscribed

如果订阅给定,则返回解析为 true 的承诺 disposable 已启动或为 false 否则

Parameters

  • disposable Disposable

返回 Promise<布尔值>

References

License

麻省理工学院:版权所有:Jumpn Limited。

@activimetrics/socket-relay

Absinthe Socket Relay

Installation

Using npm

$ npm install --save @activimetrics/socket-relay

Using yarn

$ yarn add @activimetrics/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 AbsintheSocket
  • onError function (error: Error): any

Returns FetchFunction

createSubscriber

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

Parameters

  • absintheSocket AbsintheSocket
  • onRecoverableError 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

Returns Promise<boolean>

References

License

MIT :copyright: Jumpn Limited.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文