Skip to content

Instantly share code, notes, and snippets.

@ionoy
Created February 27, 2016 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ionoy/736ae9d482d480c05177 to your computer and use it in GitHub Desktop.
Save ionoy/736ae9d482d480c05177 to your computer and use it in GitHub Desktop.
allMessages.GroupBy(msg => msg.Type)
.Select(g => g.Throttle(TimeSpan.FromSeconds(0.5)) // Ждём паузы между сообщениями
.Select(msg => HandleMessage(msg)) // HandleMessage возвращает Task<Result>
.Switch() // Если придёт новое сообщение этого типа, то старый ответ будет игнорирован
.SelectMany(res => SendResponse(res)))
.Subscribe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment