Skip to content

Instantly share code, notes, and snippets.

@janeshsutharios
Last active July 15, 2019 07:01
Show Gist options
  • Save janeshsutharios/d8b211085eed5b5f0aa25fe210776b4e to your computer and use it in GitHub Desktop.
Save janeshsutharios/d8b211085eed5b5f0aa25fe210776b4e to your computer and use it in GitHub Desktop.
Data Binding through Clousers
//Step 1:
//Create button clouser
var tapsOnButtonClouser:() -> () = {}
var isTempBool = false
//Step 2: Setup that function
func setUpClouser() {
tapsOnButtonClouser = { [weak self] in
guard let localSelf = self else {return}
localSelf.isTempBool = !localSelf.isTempBool
print("Temp Bool changed to--> ",localSelf.isTempBool)
}
}
setUpClouser()
//Step 3: Invoke that function
tapsOnButtonClouser()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment