by exit · 16y ago · 0 comments
values = '[1, 2, 3]
incremented = values.map({ n | n + 1 })
summary = incremented.join(", ")
summary.starts-with?("1").then({
fail("Increment failed.")
}) user-interface, discovery-system |
# This process is spawned with two pids as arguments
# If either pid halts, I halt too.
user-interface.link
discovery-system.link
user-interface.subscribe(when(
text-entered: { message |
# I entered a message in the UI, announce it to everyone subscribed to me
my-actor.announce('exclaimed, message)
}
))
discovery-system.subscribe(when(
peer-discovered: { name, peer |
# Discovery system located another user in the chat room
# Send message to user-interface showing a Growl style notification.
user-interface << ('notify, "{name} arrived.")
peer.subscribe(when(
# This guy went away - "halted" is announced when a process stops
halted: { result | user-interface << ('notify, "{name} left.") }
# This guy said something
exclaimed: { message | user-interface << ('text-append, "{name}: {message}") }
))
}
)
main.loop