Binding that depends on external javascript function

I have a diagram with some items in it. I have a binding of the cursor of the items where the source is an empty string and there is a conversion function that determines the value of the cursor. The conversion function returns the cursor depending on some other external javascript function that is imported. The external javascript function returns a value that depends on a setting the user can change.
As I understand when the source is an empty string we use the graphobject as the source and on every change to the object it calls the binding conversion function.
A strange thing happens. I have two items in my diagram, one is selected and one is not. When I hover over the non-selected item going in and out of the item with my mouse, the binding conversion function is called. When I hover over the selected item nothing happens.
A. How can this be? Why would the fact that an item is selected or not have to do with when the binding happens?
B. I understand that there might be an issue here that the only thing I changed was some external javascript property that does not trigger the binding function. How can I get over this issue?
Thanks,

As I understand when the source is an empty string we use the graphobject as the source and on every change to the object it calls the binding conversion function.

This is not exactly true. Empty-string bindings re-evaluate any time any a Part.data change is recorded, not any time the Part changes. So changing the value of Part.isSelected etc would not cause an empty-string binding to re-evaluate. You can use ofObject bindings if you need to evaluate something on a GraphObject property change, though.

Why not make a mouseEnter function on the Part instead of a binding? It would be simpler and could evaluate whatever you wanted every time.

B. I understand that there might be an issue here that the only thing I changed was some external javascript property that does not trigger the binding function. How can I get over this issue?

You can force any Node, or all nodes, to re-evaluate their bindings, but this is not efficient and I do not recommend it unless you really need it

I am using ofObject.
When the item is selected the binding function is not called but when it is not selected the binding function is called. Nothing to do with the change of the property isSelected because this happens with hovering over the item, not when selecting it. What can be the explanation for this strange behavior?

Is there any way to do binding so that the binding happens on changes of the object and on a change of the return value of some other external javascript function?

It would help if we could see the relevant code and a small screenshot of the problem.

How would the system know about a change in the value of a function without calling that function continuously, in case the function depended on external state which might be as changeable as the weather?

That’s why we say that ofObject Bindings cannot depend on read-only properties – it’s the GraphObject property setter that detects when there has been a change in value and thus knows to re-evaluate any bindings.

For data bindings, it’s the Model method, such as Model.set, or a Model settable property, that knows how to update the appropriate Bindings.

I think Simon’s suggestion of implementing GraphObject.mouseEnter and mouseLeave event handlers might be the simplest solution.