Skip to content

如何判断本次请求的真正触发原因 #2359

Open
@1pone

Description

@1pone

真实的请求中可能配置多种请求触发器或者请求依赖,是否可以在 onBefore/onSuccess/onFinally 判断本次请求的真正触发原因,比如是因为自动初始化请求、手动 run、手动 refresh、某个 refreshDeps 变更等,以便作出不同的响应

const { data, run, refresh } = useRequest(Service, {
      refreshOnWindowFocus: true,
      refreshDeps: [dep1, dep2],
      loadingDelay: 200,
      pollingInterval: 6000,
      onSuccess(res, params) {
      // 根据本次请求不同的触发器 trigger 进行不同的响应:run / refresh / refreshDeps[n] / refreshOnWindowFocus
      // ......
      },
    },
  );

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions