Hi Boris,
thanks for the explanations. Sorry for not providing an example, but the
problem is trivial.
There's a long running operation on my model that is triggered in a
wizard using IRunnableContext.run(boolean, boolean,
IRunnableWithProgress), with fork = true. So, model changes are
definitely not run on the UI thread.
I have situations where I have to bind to a different model object or
unbind completely. For this, I have 2 methods - bind(ModelObject) and
unbind(), where the first will create the DataBindingContext and the
latter dispose it. These are called from event handlers in my UI
component class.
In another forum thread, I discussed the problem where dispose() caused
an AssertionException. I had to wrap the call like this:
dataBindingContext.getBindings().getRealm().exec(new Runnable() {
public void run() {
dataBindingContext.dispose();
dataBindingContext = null;
}
});
Similar problem in bind(). I have to make sure that it is run on the UI
thread.
What I don't fully understand: Why do I have to worry about such thing.
Shouldn't the observables take care of this?
Where do I know in which Realm I have to create the DataBindingContext?
Is it always the target's realm, and never the model's realm?
A good point for a quote from the wiki:
"To bridge between observables in different realms, use a data binding
context - you can bind two observables even if they belong to different
realms and the bindings take care of this for you by using
Realm.asyncExec() where necessary."
I just want to understand, when and why *I* have to take care.