DeclarativeHub / Bond

A Swift binding framework
MIT License
4.23k stars 361 forks source link

Inline bond declarations not firing #58

Closed felixpalmer closed 9 years ago

felixpalmer commented 9 years ago

When creating a Bond inline (i.e. without a let declaration), the Bond is not fired on updates. Example

let numberOfFollowers = Dynamic("Initial")
let myBond = Bond<String>() { value in
    println("Pre-defined bond. value: \(value).")
}
numberOfFollowers ->> myBond
numberOfFollowers ->> Bond<String>(){ value in
    println("Inline bond. value: \(value).")
}
numberOfFollowers.value = "Some Followers"

When this is run, the update to Some Followers is only fired on the pre-defined Bond, i.e. the log output is:

Pre-defined bond. value: Initial.
Inline bond. value: Initial.
Pre-defined bond. value: Some Followers.
felixpalmer commented 9 years ago

Forgot to say: version 3.7

srdanrasic commented 9 years ago

Hi @felixpalmer, This is expected. Bond object has to be retained by someone. Usually you would have it defined as a property so it would be retained by self.

felixpalmer commented 9 years ago

OK makes sense. I should have read the docs more closely. Not sure if it is possible, but it would be great if the framework could catch when an unretained Bond like this is created, and warn the user

ahmedtarek- commented 9 years ago

@felixpalmer hello there! I wanted to ask you about the android visualizer code! I am trying to edit the for loop which generate the points in onRender() method in LineRenderer class to only have a thin line that plays with music without all the other graphs. But I can't find a way to do that, any help?

tonyarnold commented 9 years ago

@ahmedtarek- I think you're in the wrong place. This project is for Swift on Apple's platforms, not for Android.