Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using a simple Bond<T> to propagate side effects #53

Closed
JustinTulloss opened this issue Apr 21, 2015 · 3 comments
Closed

Using a simple Bond<T> to propagate side effects #53

JustinTulloss opened this issue Apr 21, 2015 · 3 comments

Comments

@JustinTulloss
Copy link

I'm having some trouble figuring out how to use a bond for things that are not necessarily value transforms.

For instance, if I want to change the height of my label based on the updated text, I thought I could do something like this:

textLabel.dynText ->> Bond<String>() { _ in
    textLabel.sizeToFit()
}

However, that seems to only fire once. Changing the textLabel (even via another bond) does not cause the function to fire again.

Am I missing something?

@zdnk
Copy link

zdnk commented Apr 22, 2015

you need to retain the bond

@JustinTulloss
Copy link
Author

Ok. Seems like I probably should have thought of that, but it wasn't obvious to me from the docs.

Thanks!

@JustinTulloss
Copy link
Author

(And I see that it's explicitly stated in the docs now, it's just not actually spelled out in the examples)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants