Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug Report] 钩子函数有顺序问题 #159

Open
gexin1 opened this issue Dec 21, 2019 · 1 comment
Open

[Bug Report] 钩子函数有顺序问题 #159

gexin1 opened this issue Dec 21, 2019 · 1 comment

Comments

@gexin1
Copy link

gexin1 commented Dec 21, 2019

we-cropper 版本

0.1.0

对应工具或者iOS或者Andriod的版本号

android

微信版本号

2.9.4

重现步骤

function observer () {
  var self = this;
  self.on = function (event, fn) {
    if (EVENT_TYPE.indexOf(event) > -1) {
      if (tools_7(fn)) {
        event === 'ready'
          ? fn(self)
          : self[("on"   (firstLetterUpper(event)))] = fn;
      }

    } else {
      console.error(("event: "   event   " is invalid"));
    }
    return self
  };
}

当我ready写在beforeImageLoad 前边
我在ready回调中执行pushOrign方法 就会直接执行
此时 beforeImageLoad 还没有绑定到 onBeforeImageLoad
beforeImageLoad不会执行

期待的行为

在文档中强调一下钩子函数的执行顺序

实际的行为

@gexin1
Copy link
Author

gexin1 commented Dec 22, 2019

      if (tools_7(fn)) {
        event === 'ready'
          ? Promise.resolve().then(()=>{fn(self)})
          : self[("on" + (firstLetterUpper(event)))] = fn;
      }

是否可以异步执行 ready 钩子函数

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants