Files
apollo/docs/zh-cn/api/smart-subscription.md
T
高英健 d83a18fb4f docs: sync Chinese doc to 3.0.0-beta.28 (#509)
Just a suggestion: maybe a stable version of vue-apollo can be published after this wonderful ssr refactor?
2019-02-20 12:58:40 +01:00

925 B

智能订阅

每个在组件中的 apollo.$subscribe 选项中声明的订阅都会创建一个智能订阅对象。

选项

  • query:GraphQL 文档(可以是一个文件或一个 gql 字符串)。
  • variables:对象或返回对象的响应式函数。每个键将用 '$' 映射到 GraphQL 文档中,例如 foo 将变为 $foo
  • throttle:变量更新节流时间(毫秒)。
  • debounce:变量更新防抖时间(毫秒)。
  • result(data, key) 是收到结果时调用的钩子。

属性

Skip

你可以使用 skip 来暂停或停止暂停:

this.$apollo.subscriptions.users.skip = true

方法

refresh

停止并重新启动查询:

this.$apollo.subscriptions.users.restart()

start

开始查询:

this.$apollo.subscriptions.users.start()

stop

停止查询:

this.$apollo.subscriptions.users.stop()