Skip to content

Instantly share code, notes, and snippets.

@azenla
Last active December 10, 2015 18:39
Show Gist options
  • Save azenla/a579d4c7c063869efd96 to your computer and use it in GitHub Desktop.
Save azenla/a579d4c7c063869efd96 to your computer and use it in GitHub Desktop.
type Socket {
property host: String
property port: Integer
emits @connected: Socket
emits @data: any
constructor(self.host, self.port)
function connect() -> void {
@connected <- self
}
operator <-(data: any) = @data <- data
@data(data: any) {
print(data)
}
}
let socket = Socket("google.com", 80)
socket@connected { e ->
print("Connected!")
socket <- "Hello World"
}
socket.connect()
if socket is Socket {
print("Object is a Socket")
}
if socket has connect() {
print("Socket has a connect() method")
}
let list = [1, 2, 3]
list@changed { e ->
if e.isAddEvent {
print("Added $(e.value)")
}
}
list <- 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment