Closed long-nguyen closed 2 years ago
Hi,
the library is completely agnostic in terms of how you handle your refreshing, which also includes how you cancel it. In other words, something like this would work:
RefreshableScrollView(onRefresh: { done in
isLoading = true
DispatchQueue(label: "background").async {
while isLoading { }
done()
}
},
As far as triggering the refresh action by setting isLoading
to true
, I need to think about it a bit more. It's certainly a possibility.
@gordan-glavas-codecons thank you. But the done() event, how can I call it in another functions outside the onRefresh callback like above?
It's just a block you can pass it around any way you want. You can even store it in a state var:
@State private var refreshBlock: RefreshComplete? = nil
...
RefreshableScrollView(onRefresh: { done in
refreshBlock = done
}
// call refreshBlock?() elsewhere
@gordan-glavas-codecons Thank you, great!
Hi, thank you for your great implementation. How could I achieve things like using @State var loading = false to control when the refreshing action should be finish. Thanks