Guest User

Untitled

a guest
Dec 30th, 2019
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 0.37 KB | None | 0 0
  1. class Output<U : Term>(val name: String) {
  2.  
  3.     private val callbacks: MutableList<suspend (U) -> Boolean> = mutableListOf()
  4.  
  5.     fun connect(input: Input<out U>) {
  6.         // input.callback is suspend (U) -> Boolean
  7.         this.callbacks.add(input.callback)
  8.     }
  9.  
  10.     suspend fun yield(term: U) {
  11.         callbacks.forEach {
  12.             it(term)
  13.         }
  14.     }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment