Created
September 20, 2021 19:14
-
-
Save serhiybutz/5024131300861dc2e47f33d8ea17a703 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Foo { | |
let sharedCounter = Shared(value: 0) | |
let sharedName = Shared(value: "") | |
let sm = SharedManager() | |
func reset() { | |
sm.borrow(sharedCounter, sharedName) { sharedCounter, sharedName in | |
sharedCounter.value = 0 | |
sharedName.value = "" | |
} | |
} | |
func setName(_ name: String) { | |
sm.borrow(sharedName) { sharedName in | |
sharedName.value = name | |
} | |
} | |
func incFoo() { | |
sm.borrow(sharedCounter) { sharedCounter in | |
sharedCounter.value += 1 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment