Created
November 13, 2019 14:21
-
-
Save jdmichaud/5cb0be6a7e1772ff8b8c10af51e1a874 to your computer and use it in GitHub Desktop.
Observable Design
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef std::function<std::function<void()>(Observer<T>)> SubscriberFunction<T>; | |
interface Subscription<T> { | |
Subscription<T>(Observer<T>, SubscriberFunction<T>); | |
void unsubscribe(); | |
} | |
interface Observer<T> { | |
void start(Subscription<T>); | |
void next(const T&); | |
void error(const std::exception&); | |
void complete(); | |
} | |
interface Observable<T> { | |
Observable<T>(SubscriberFunction<T>); | |
Subscription &subscribe(Observer<T>); | |
Subscription &subscribe(std::function<void(const T&)); | |
} | |
interface Subject<T> extends Observable<T> { | |
Subject<T>(); | |
void next(const T&); | |
void error(const std::exception&); | |
void complete(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment