Skip to content

Commit

Permalink
Call completion after delegate methods
Browse files Browse the repository at this point in the history
  • Loading branch information
cysp committed May 3, 2019
1 parent a79279b commit 5f3135d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions Sources/DVR/SessionDataTask.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ final class SessionDataTask: URLSessionDataTask {
fatalError("[DVR] Something has gone horribly wrong.")
}

self._state = .completed
self.session.finishTask(self, interaction: interaction, playback: true)

// Forward completion
if let completion = self.completion {
completion(interaction.responseData, interaction.response, nil)
}

self._state = .completed
self.session.finishTask(self, interaction: interaction, playback: true)
}
return
}
Expand Down Expand Up @@ -90,13 +90,13 @@ final class SessionDataTask: URLSessionDataTask {
fatalError("[DVR] Something has gone horribly wrong.")
}

self.completion?(data, response, nil)

self._state = .completed

// Create interaction
self.interaction = Interaction(request: self.request, response: response, responseData: data)
self.session.finishTask(self, interaction: self.interaction!, playback: false)

self.completion?(data, response, nil)
}
})
task.resume()
Expand Down

0 comments on commit 5f3135d

Please sign in to comment.