From 961f81c456c8850afcb23797d7cfcddfecff2d2b Mon Sep 17 00:00:00 2001
From: DarMontou
- In order to complete this course, you will need this following:
+ In order to complete this course, you will need the following:
Welcome
Requirements
Getting started
-
\ No newline at end of file
+
From 4e103a7a3fb7f1e66b0abaf9e4eae6cca8f6bae2 Mon Sep 17 00:00:00 2001
From: DarMontou About core.async
The historical roots of core.async trace all the way back to Hoare’s Communicating
Sequential Processes (CSP). One of the most immediate inspirations for core.async is the
Go programming language. Fundamentally, one of the principles behind CSP is
- that coordination between concurrent processes is achieved via message-passing. In core.async, this achieved
+ that coordination between concurrent processes is achieved via message-passing. In core.async, this is achieved
through the use of queue-like channels.
Nonetheless, this asynchronous variant would work just fine in ClojureScript. The only price we have to pay
is a small sampling of callback hell. But what if there was a way to maintain the readability of the
- synchronous function buy still enjoy the benefits of asynchronous operation? Well, let’s check out what
+ synchronous function but still enjoy the benefits of asynchronous operation? Well, let’s check out what
go can do for us:
go
The <! function takes a value from the channel. This function can only be used in the
- context context of a go. This will allow the loop to park until it has a value. It’s
- nice because it allow you to write code to appear as if the code blocks at that point without actually
+ context of a go. This will allow the loop to park until it has a value. It’s
+ nice because it allows you to write code to appear as if the code blocks at that point without actually
blocking.
We use a when-let because the channel will always produce a non-null value. If we get a
- null value, that indicates the channel was closed. This also means you can not put a null value into
+ null value, that indicates the channel was closed. This also means you cannot put a null value into
a channel. If there is a chance the channel will produce a false value, you can use
when-some instead, which was introduced in Clojure 1.6.
close! on the channel.
- This idempotent call will cause the channel to longer accept new values, but will allow readers to
+ This idempotent call will cause the channel to no longer accept new values, but will allow readers to
continue reading values until the channel is exhausted.
@@ -190,4 +190,4 @@ mult in practice- Now the only bit of functionality you will need to use in mult-channel properly is to ensure that when - the client disconnects you shut down things down properly: + Now the only bit of functionality you will need to use a mult-channel properly is to ensure that when + the client disconnects you shut things down properly:
(async/untap! subscribe-channel chat-events) (async/close! chat-events)@@ -127,4 +127,4 @@
async-workshop.chat-demo namespace. The client (ClojureScript) code will be under
- async-workshop.chat-demo.client, and the server (Clojure) code will be under
+ async-workshop.chat-demo namespace. The client (ClojureScript) code is under
+ async-workshop.chat-demo.client, and the server (Clojure) code is under
async-workshop.chat-demo.server.
(om/root chat-input-widget app-state
{:target (.getElementById js/document "chatInputWidget")})
- Note that in this example, the chat-input-widget var has ben referred.
+ Note that in this example, the chat-input-widget var has been referred.
- Now that there is a place to put the message, let’s modify send-message to the job. The
+ Now that there is a place to put the message, let’s modify send-message to do the job. The
code for this is fairly straightforward. Just dereference the cursor passed in to get access to the
channel:
- In this section, we’ve primary learned how to use multiple channels together using alts!.
+ In this section, we’ve primarily learned how to use multiple channels together using alts!.
In the next section, we’ll start seeing how we can use this technique together with several other
new ones to get multiple clients actually talking to each other.