kujiale / tacky

Enterprise-level front-end framework based on react

Home Page:https://kujiale.github.io/tacky/#/zh-cn/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

effect can return value for abort api call

geoffgu opened this issue · comments

@effect
async fetch() {
  let pendingRequest = API.call(); // promise
  this.$update({ isLoading: true });

  function autoRun() {
    const result = await pendingRequest;
    this.$update({ isLoading: false, result });
  }

  function abort() {
    pendingRequest.abort();
  }
  
  return {
    abort,
    autoRun,
  }
}

enhance effect