|
|
@@ -33,15 +33,17 @@ public class IndirectObservableListener<C, T> {
|
|
|
*/
|
|
|
public void setObserved( T obs, Observable... extra ) {
|
|
|
Objects.requireNonNull( obs );
|
|
|
- if ( obs == model && (extra.length == 0 || extra[0] == obs) ) return;
|
|
|
// Make sure that we aren't listening to any of the previous things.
|
|
|
// This means that we can re-use objects instead of destroying and re-making a
|
|
|
// bunch of high-level GUI objects any time the model changes.
|
|
|
ObserverDispatch.unsubscribeAll( this );
|
|
|
+ final boolean hasChanged = (obs != model);
|
|
|
model = obs;
|
|
|
// Invoke the update callback - our parent does not need to update the
|
|
|
// {@see component} manually.
|
|
|
- updateComponent( );
|
|
|
+ if (hasChanged) {
|
|
|
+ updateComponent( );
|
|
|
+ }
|
|
|
for ( int i = 0, n = extra.length; i < n; ++i ) {
|
|
|
ObserverDispatch.subscribe( extra[i], this, this::updateComponent );
|
|
|
}
|