I have got a generic question to anyone that can help:
Lambdas retain reference to outer-class. What happens when the outer-class dies while lamba’s class is still alive?
Example: In Android Fragments
class myFragment: Framgnet {
…
onActivityCreated() {
//Make an API request in the background (that might take 3 or 5 secs to finish)
myNetworkClient.getAllUserAddresses(userId, { addresses ->
//Update UI with the list of addresses fetched
//*What happens here if the user went out of the fragment before the API request was finished ??*
//Memory leak ? Crash ? Nothing?
})
}
..
}