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

使用HWthrottle碰到的问题 #1

Open
zziazm opened this issue Sep 7, 2023 · 0 comments
Open

使用HWthrottle碰到的问题 #1

zziazm opened this issue Sep 7, 2023 · 0 comments

Comments

@zziazm
Copy link

zziazm commented Sep 7, 2023

大佬,我用了这种HWThrottleModeLeading模式,写了个代码想测试下连续点击的问题:

  • (void)testThrottle {
    [self.testThrottler call];
    [self.testThrottler call];
    }
    我在方法里连续调用了两次call想模拟连续点击的情况,发现还是连续调用了两次,应该是第二次call的时候dispatch_async的block还没执行,lastRunTaskDate没有更新:
  • (void)runTaskDirectly {
    dispatch_async(self.queue, ^{
    if (self.taskBlock) {
    self.taskBlock();
    }
    self.lastRunTaskDate = [NSDate date];
    });
    }
    如果把 self.lastRunTaskDate = [NSDate date];放到dispatch_async外面是不是可以解决这个问题呢?
@zziazm zziazm changed the title 使用HWthrottle的问题 使用HWthrottle碰到的问题 Sep 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant