Skip to content

Instantly share code, notes, and snippets.

@tanitta
Created September 20, 2017 12:39
Show Gist options
  • Select an option

  • Save tanitta/eb6f79dff538749ff69359f81b5f17d2 to your computer and use it in GitHub Desktop.

Select an option

Save tanitta/eb6f79dff538749ff69359f81b5f17d2 to your computer and use it in GitHub Desktop.
module syncbox;
import rx;
///
struct SyncableObserver{
public{
void put(Event n){}
// void put(int n){} : linker error
}//public
}//struct SyncableObserver
///
struct Event {
public{
int amount;
}//public
}//struct Event
///
class SyncBox{
public{
this(){
_subject = new SubjectObject!Event;
_syncObserver = SyncableObserver();
_subject.doSubscribe(_syncObserver);
}
void listen(Event event){
// data += event.amount;
// _subject.put(event);
}
}//public
private{
int data;
SubjectObject!Event _subject;
SyncableObserver _syncObserver;
}//private
}//class SyncBox
unittest{
auto box = new SyncBox;
auto e = Event();
e.amount = 1;
box.listen(e);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment