-------- Hash hash; void onData(void[] data) { hash.put(data); }
void main() { hash.start(); auto stream = new EventTcpStream("localhost", 80); stream.onData = &onData; hash.finish(); } --------
Have the callback supply a range interface to call the hash with.
That hardly works for event based programming without using coroutines.It's the classical inversion-of-control dilemma of event based programming that forces you to save/restore your state with every event.