Addicted to MicroObservables

Very often it is necessary to use an obervable-pattern in its basic structure, which means that the observable notifies registered observers after its internal state has changed.

This implementation concept is very static and has the side effect that the observers are notified every time the model has changed regardless of which change they are interested in.

In this case it is recommended to use a more dynamic approach like an specific observable.

But if you only have one value in the model which changes, the MicroObservable structure could be very useful.

To be more generall, this implementation is basically a rudimentary way of an generic remote proxy. This comparison leaks in some way, but point out the advantages.

The following uml-diagram shows the dependencies between the participants:
Micro Observer UML

After the value is available (setted from outside) the MicroObservable notifies all registered MicroObservers with its internal notifyObservers() method.

public function set value( value: * ): void
{
	_value = value;
 
	_hasChanged = true;
 
	notifyObservers();
}

The classes can be found in the addicted2flash library.

2 Responses (Add Your Comment)

  1. Try this,


    public function set value( value: * ): void
    {
    if(_value != value)
    {
    _value = value;
    _hasChanged = true;
    notifyObservers();
    }
    }

    Observer pattern is very flexible.

  2. Thanks for your response. I really forgot to check this. Your addition makes sence. I have just implemented it in the MicroObservable.

Leave a Reply

Formatting: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>