Ready State #Facebook Relay文档翻译#
来源:互联网 发布:知金教育靠谱吗 编辑:程序博客网 时间:2024/05/17 21:55
原文地址
上一篇 Root Container
Relay文档翻译目录
Whenever Relay is fulfilling data requirements, it can be useful to know when certain events occur. For example, we might want to record how long it takes for data to be available, or we might want to log errors to the server. These events are available on most Relay APIs via the onReadyStateChange
callback.
当Relay在满足数据需求的过程中,知道特定事件的发生状态是很有用的。例如,我们想知道数据获取花了多长时间,如我们想向服务器端写日志。这些事件在大多数Relay API上通过onReadyStateChange
都是可以监听到的。
onReadyStateChange
When Relay fulfills data, the onReadyStateChange
callback is called one or more times with an object that describes the current “ready state”. This object has the following properties:
当Relay执行数据需求时,onReadyStateChange
被调用一次或多次,包含一个描述当前”ready state”的对象。它有如下属性:
ready: boolean
This is true when the subset of data required for rendering is ready.
为真表示所需数据的子集准备完毕done: boolean
This is true when all data requirements are ready for rendering.
为真表示所有需要的数据准备完毕error: ?Error
This is an instance of
Error
if there is a failure. Otherwise, this isnull
.
如果发生错误,将有一个Error实例,负责为nullstale: boolean
When “force fetching”, this is true if
ready
is true as a result of data being available on the client before the server request has completed.
当强制从服务器端获取数据时,全部数据获取完毕之前,当ready为真时它为真。aborted: boolean
Whether the request was aborted.
请求失败被中断。
Examples
Fetching Data from the Server
If insufficient data on the client leads Relay to send a server request for more data, we can expect the following behavior:
如果客户端没有足够的数据,Relay向服务器端发送数据请求,将有下面的行为:
- Once with
ready
set to false. - Once with
ready
anddone
set to true.
Resolving Data from the Client
If sufficient data is available on the client such that Relay does not need to send a server request, we can expect the following behavior:
如果客户端有足够的数据,Relay不需要向服务器端发送数据请求,将有下面的行为
- Once with
ready
anddone
set to true.
Server Error
If a server request results in a failure to load data, we can expect the following behavior:
如果获取数据的服务器端请求失败,将有下面行为:
- Once with
ready
set to false. - Once with
error
set to anError
object.
Note that ready
and done
will continue to be false.
Force Fetching with Data from the Client
If a “force fetch” occurs and there is insufficient data on the client, the same behavior as Fetching Data from the Server can be expected. However, if a “force fetch” occurs and there is sufficient data on the client to render, we can expect the following behavior:
当强制从服务器端获取数据,并且客户端数据不足时,与Fetching Data from the Server的情况相同。如果强制从服务器端获取数据,客户端数据已经满足的情况下,将有下面行为:
- Once with
ready
,done
, andstale
set to true. - Once with
ready
anddone
set to true, butstale
set to false.
- Ready State #Facebook Relay文档翻译#
- Babel Relay Plugin #Facebook Relay文档翻译#
- GraphQL Relay Specification #Facebook Relay文档翻译#
- Thinking In Relay #Facebook Relay文档翻译#
- Tutorial #Facebook Relay文档翻译#
- Containers #Facebook Relay文档翻译#
- Routes #Facebook Relay文档翻译#
- Mutations #Facebook Relay文档翻译#
- Connection #Facebook Relay文档翻译#
- Mutations #Facebook Relay文档翻译#
- Relay文档翻译目录 #Facebook Relay文档翻译#
- Getting Start #Facebook Relay文档翻译#
- Root Container #Facebook Relay文档翻译#
- Network Layer #Facebook Relay文档翻译#
- Object Identification #Facebook Relay文档翻译#
- Thinking in GraphQL #Facebook Relay文档翻译#
- state-threads官方文档介绍篇翻译
- state-threads官方文档编程注意篇翻译
- socket库基于ios android封装
- C++的那些事:类的拷贝控制
- 潜意识的6大特征
- 用java写一个main函数实现排列组合
- 初学android 运行模拟器
- Ready State #Facebook Relay文档翻译#
- android webview对shouldOverrideUrlLoading的理解,对于重定向的url
- 认真看待360
- sqlite 日期类型
- 菜鸟成长记(1)——cocos2dx-2048小游戏实战之界面布局
- 元数据(Metadata)
- linux权限和用户管理
- 黑马程序员---java基础----String类
- Unity3d中UI开发的MVC模式