Using streams to define event-driven components