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

The elastic effect getting stuck with a whole or half loading circle when async data. #69

Open
aloveric opened this issue Jul 10, 2017 · 2 comments

Comments

@aloveric
Copy link

screen shot 2017-07-10 at 10 57 20 am

@michaelschwinges
Copy link

I have users reporting this behavior, too. Not sure how to replicate it.

@danipralea
Copy link

danipralea commented Oct 18, 2022

had this bug as well.
You need to separate the API async stuff from the main thread (UI) one

func setupPullToRefresh() {
        let loadingView = DGElasticPullToRefreshLoadingViewCircle()
        loadingView.tintColor = .coralPink
        tableView.dg_addPullToRefreshWithActionHandler({ [weak self] () -> Void in
            guard let self = self else { return }
            self.viewModel.isRefreshing = true
            Task {
                do {
                    try await self.refreshData()
                    self.viewModel.isRefreshing = false
                    DispatchQueue.main.async {
                        self.tableView.dg_stopLoading()
                        self.tableView.reloadData()
                        self.updateUI()
                    }
                } catch {
                    self.tableView.dg_stopLoading()
                    print("error : \(error)")
                    self.viewModel.isRefreshing = false
                }
            }
            
        }, loadingView: loadingView)
        tableView.dg_setPullToRefreshFillColor(AppColor.whiteThree)
        tableView.dg_setPullToRefreshBackgroundColor(tableView.backgroundColor ?? .white)
    }
    
    private func refreshData() async throws {
        try await viewModel.loadUserEvent()
        try await viewModel.fetchDesigns()
        try await viewModel.fetchWinners()
    }

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

3 participants