Created
August 3, 2018 22:35
-
-
Save maltzsama/c72c70cd436d222c5bde6663a0e822ec to your computer and use it in GitHub Desktop.
scala observer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.accenture.viavarejo.boasvindas.observers | |
import scala.collection.mutable | |
class SOAP(private val xml: Any){ | |
def slot(xml: String) = println(s"recebi samerda: $xml") | |
} | |
class ETL(private val json: Any) { | |
def slot(json: String) = { | |
println(s"recebi a mensagem: $json") | |
val xml = json | |
this.emmitSignal(xml) | |
} | |
var subscribers = new mutable.HashSet[SOAP]() | |
def subscribe(sub: SOAP) = this.subscribers.add(sub) | |
def remove(sub: SOAP) = this.subscribers.remove(sub) | |
def emmitSignal(message: String) = this.subscribers.foreach(_.slot(message)) | |
} | |
class KafkaConsumer() { | |
var subscribers = new mutable.HashSet[ETL]() | |
def registrar(subscriber:BoasVindasSubscriber) = this.subscribers.add(subscriber) | |
def remover(subscriber: BoasVindasSubscriber) = this.subscribers.remove(subscriber) | |
def emmitSignal(mensagem: String) = this.subscribers.foreach(_.slot(mensagem)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment