Skip to content

Unsubscribe / Multiple subscriptions #11

Description

@rzeldent

To subscribe to an observable this can be done by creating a class that implements IObserver and subscibe.
However, it is not possible to unsubscribe. When subscribing a reference should be returned so that an observer can unsubscribe.

The IObserver *_observer; should be iterable, so become a list/array and all the observers should be called.

See, for example the Observable base:

  • Subscibe does not return a reference, but void.
  • The _observer is only a single observer. but should be some list.
template <typename T>
class ObservableProperty : public Observable<T>
{
public:
	void operator = (const T&);
	ObservableProperty();
	void Subscribe(IObserver<T> &) override;
	void Finish();
	void Reset() override;

private:
	IObserver<T> *_observer;
	bool _complete = false;
};

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions