alpha-wallet-ios icon indicating copy to clipboard operation
alpha-wallet-ios copied to clipboard

Refactor PromptViewController to replace the delegate with with 1-2 closures

Open hboon opened this issue 2 years ago • 0 comments

After #6034

This approach shouldn't be employed for the entire codebase, but it makes the client code better for the type of work PromptViewController does. For example. when enabling/disabling testnets, the client code is like this:

if userTabToEnableTestnet
    promptUserWithPromptViewController
else
    proceed
    enableTestnet(false)
end

//…lots of code in between
//…lots of code in between
//…lots of code in between
//…lots of code in between

//Somewhere else
func actionButtonTapped(inController controller: PromptViewController)
    enableTestnet(true)
end

The 2 pair of calls for enableTestnet() are too far from each other.

Watch out for weak references

hboon avatar Mar 01 '23 06:03 hboon