Skip to content
This repository was archived by the owner on Aug 24, 2019. It is now read-only.
This repository was archived by the owner on Aug 24, 2019. It is now read-only.

Delegate Callback Behavior #64

@calebd

Description

@calebd

Programatic invocations of startLoading should not cause the delegate method pullToRefreshViewDidStartLoading: to be called. This should only be called on user-initiated events.

The example in SSPullToRefreshView.h is a good example of this issue:

- (void)refresh {
   [self.pullToRefreshView startLoading];
   // Load data...
   [self.pullToRefreshView finishLoading];
}

- (void)pullToRefreshViewDidStartLoading:(SSPullToRefreshView *)view {
   [self refresh];
}

Consider the following scenario given the above code:

  • View controller is sent viewDidAppear:
  • refresh is called to trigger a first load
  • startLoading is called so that the refresh control reflects the current loading state
  • pullToRefreshViewDidStartLoading: is called during the state transition
  • refresh is called again

SSPullToRefreshView prevents that from continuing in an infinite loop, but I now have multiple instances of refresh running for what should have been a single invocation.

The only way I have found around this is to override startLoading and wrap the call to super by temporarily removing the delegate. Alternatively, any consumer is required to track loading state to prevent a single invocation of refresh from firing multiple loads.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions