@@ -4,7 +4,7 @@ weight = 6
44template = "doc.html"
55+++
66
7−Here we'll look at reading files and subscribing to changes. We'll do this by sending clay a `card:agent:gall` containing a `%warp` tagged `task:clay`.
7+Here we'll look at reading files and subscribing to changes. We'll do this by sending Clay a `card` containing a `%warp` `task`.
88
99## Contents
1010
@@ -12,12 +12,12 @@ Here we'll look at reading files and subscribing to changes. We'll do this by se
1212- [%sing](#sing) - Read a single file or directory.
1313- [%next](#next) - Subscribe for the next change to a file or directory.
1414- [%mult](#mult) - Subscribe for the next change to a set of files and/or directories.
15−- [%many](#many) - Track changes to a desk for the specified range of revisions.
15+- [%many](#many) - Track changes to a `desk` for the specified range of revisions.
1616- [Cancel Subsciption](#cancel-subscription)
1717
1818## Introduction
1919
20−A `%warp` task looks like:
20+A `%warp` `task` looks like:
2121
2222```hoon
2323[%warp wer=ship rif=riff] :: internal file req
@@ -29,7 +29,7 @@ The `riff` part is the following structure:
2929+$ riff [p=desk q=(unit rave)] :: request+desist
3030```
3131
32−The `desk` is the desk in question. The `(unit rave)` is null to cancel a subscription, otherwise the `rave` is:
32+ The `(unit rave)` is null to cancel a subscription, otherwise the `rave` is:
3333
3434```hoon
3535+$ rave :: general request
@@ -47,15 +47,15 @@ The `desk` is the desk in question. The `(unit rave)` is null to cancel a subscr
4747
4848We'll look at each of these in more detail later.
4949
50−Clay responds to a `%mult` request with a sign containing a `%wris` tagged `gift:clay`, and the rest with a `%writ`.
50+Clay responds to a `%mult` request with a `sign` containing a `%wris` `gift`, and the rest with a `%writ` `gift`.
5151
52−A `%wris` gift looks like:
52+A `%wris` `gift` looks like:
5353
5454```hoon
5555[%wris p=[%da p=@da] q=(set (pair care path))] :: many changes
5656```
5757
58−A `%writ` gift looks like:
58+A `%writ` `gift` looks like:
5959
6060```hoon
6161[%writ p=riot] :: response
@@ -93,9 +93,9 @@ This is for reading a single file or directory immediately. The `mood` structure
9393+$ mood [=care =case =path] :: request in desk
9494```
9595
96−The `care` is `%x`, `%y` or whatever else. This will determine what you can read and what type of data will be returned. See the type documentation and scry documentation for details on the various cares.
96+The `care` is `%x`, `%y` or whatever else. This will determine what you can read and what type of data will be returned. See the type documentation and scry documentation for details on the various `care`s.
9797
98−The `case` specifies the desk revision and looks like:
98+The `case` specifies the `desk` revision and looks like:
9999
100100```hoon
101101+$ case :: ship desk case spur
@@ -155,7 +155,7 @@ You should see something like this as the output:
155155]
156156```
157157
158−The `cage` in the `riot` contains the file's data due to our use of an `%x` care. It needn't be an `%x` though. If we change it to `%u`, for example, we'll get a `?` cage instead:
158+The `cage` in the `riot` contains the file's data due to our use of an `%x` `care`. It needn't be an `%x` though. If we change it to `%u`, for example, we'll get a `?` `cage` instead:
159159
160160```hoon
161161> -read-file /gen/hood/hi/hoon
@@ -167,7 +167,7 @@ The `cage` in the `riot` contains the file's data due to our use of an `%x` care
167167]
168168```
169169
170−Here's a breakdown of the task we sent:
170+Here's a breakdown of the `task` we sent:
171171
172172
173173
@@ -179,7 +179,7 @@ Here's a breakdown of the task we sent:
179179
180180This subscribes to the next version of the specified file. The `mood` structure is the same as described in the `%sing` example.
181181
182−If you subscribe to the current case of the desk, clay will not respond until the file changes. If you subscribe to a previous case of the desk and the file has changed in between then and now, it will immediately return the first change it comes across in that range. For example, if you're currently at case `100`, subscribe to case `50` and the file in question has been modified at both `60` and `80`, clay will immediately return the version of the file at case `60`.
182+If you subscribe to the current `case` of the `desk`, Clay will not respond until the file changes. If you subscribe to a previous `case` of the `desk` and the file has changed in between then and now, it will immediately return the first change it comes across in that range. For example, if you're currently at `case` `100`, subscribe to case `50` and the file in question has been modified at both `60` and `80`, clay will immediately return the version of the file at `case` `60`.
183183
184184`sub-next.hoon`
185185
@@ -208,7 +208,7 @@ If you subscribe to the current case of the desk, clay will not respond until th
208208(pure:m !>(~))
209209```
210210
211−This thread will subscribe to the next version of the file given as an argument. It will print the `riot` it gets back from clay and will also print a message saying whether the file's been deleted or changed.
211+This thread will subscribe to the next version of the file given as an argument. It will print the `riot` it gets back from Clay and will also print a message saying whether the file's been deleted or changed.
212212
213213Save this in `ted/sub-next.hoon`, `|commit %home` and run like:
214214
@@ -255,9 +255,9 @@ Here's a breakdown of the task we sent:
255255[%mult =mool] :: next version of any
256256```
257257
258−This subscribes to the next version of a set of files or directories. Clay will only send a single response, and it will send it when *any* of the specified files change. For example, if you subscribe to both `/foo/txt` and `/bar/txt`, and only `/foo/txt` changes, clay will send a response indicating a change to `/foo/txt`. If `/bar/txt` changes subsequently, it will not tell you. If more than one file changes at once, it will tell you about each of the changes in the one response.
258+This subscribes to the next version of a `set` of files or directories. Clay will only send a single response, and it will send it when *any* of the specified files change. For example, if you subscribe to both `/foo/txt` and `/bar/txt`, and only `/foo/txt` changes, Clay will send a response indicating a change to `/foo/txt`. If `/bar/txt` changes subsequently, it will not tell you. If more than one file changes at once, it will tell you about each of the changes in the one response.
259259
260−The behaviour with respect to requesting old cases is the same as explained in the [`%next`](#next) section above.
260+The behaviour with respect to requesting old `case`s is the same as explained in the [`%next`](#next) section above.
261261
262262The `mool` specified in the request is this structure:
263263
@@ -265,11 +265,11 @@ The `mool` specified in the request is this structure:
265265+$ mool [=case paths=(set (pair care path))] :: requests in desk
266266```
267267
268−You can use a different `care` for each of the files specified by the `path` if you like. Significantly, the `care` will determine whether clay sends a response for a given change. For example, if you subscribe to an existing `/foo/txt` with a `%u` care and `/foo/txt` is modified but isn't deleted, clay will *not* tell you. However, if you subscribe with an `%x` care, it *will* tell you.
268+You can use a different `care` for each of the files specified by the `path` if you like. Significantly, the `care` will determine whether Clay sends a response for a given change. For example, if you subscribe to an existing `/foo/txt` with a `%u` `care` and `/foo/txt` is modified but isn't deleted, Clay will *not* tell you. However, if you subscribe with an `%x` `care`, it *will* tell you.
269269
270270Example:
271271
272−This thread will subscribe to `/foo/txt` with an `%x` care and `/bar/txt` with a `%u` care. It will print out the `%wris` it gets back from clay.
272+This thread will subscribe to `/foo/txt` with an `%x` `care` and `/bar/txt` with a `%u` `care`. It will print out the `%wris` it gets back from Clay.
273273
274274`sub-mult.hoon`
275275
@@ -305,7 +305,7 @@ Save the above to `ted/sub-mult.hoon`, `|commit %home` and run with `-sub-mult`.
305305+ /~zod/home/151/bar/txt
306306```
307307
308−You'll notice that, unlike a `%writ`, the `%wris` doesn't give you the data. It merely tells gives you the cares and paths of the files that changed. If you need to actually get the data, you can just scry or send a request for the files in question.
308+You'll notice that, unlike a `%writ`, the `%wris` doesn't give you the data. It merely tells you the `care`s and `path`s of the files that changed. If you need to actually get the data, you can just scry or send a request for the files in question.
309309
310310Now, run the thread again, open `bar.txt` in an editor, modify its contents, save it and `|commit %home`. You'll notice you didn't receive a `%wris`. This is because we subscribed to `/bar/txt` with `%u` care and its existence didn't change.
311311
@@ -320,7 +320,7 @@ Lastly, delete `foo.txt` and `|commit %home`. You should see something like:
320320
321321As you can see, a relevant change to any of the subscribed files will trigger a response, not just when all of them change.
322322
323−Here's a breakdown of the task we sent:
323+Here's a breakdown of the `task` we sent:
324324
325325
326326
@@ -330,7 +330,7 @@ Here's a breakdown of the task we sent:
330330[%many track=? =moat] :: track range
331331```
332332
333−This subscribes to all changes to a desk for the specified range of cases. Note that you're unlikely to use this directly, it's mostly used implicitly if you make a `%sing` or `%next` request with a `%v` care to a foreign desk. It's basically what the system uses to keep in sync with a foreign desk. Regardless, we'll have a look at it for completeness.
333+This subscribes to all changes to a `desk` for the specified range of `case`s. Note that you're unlikely to use this directly, it's mostly used implicitly if you make a `%sing` or `%next` request with a `%v` `care` to a foreign `desk`. Regardless, we'll have a look at it for completeness.
334334
335335If the `track` is `%.y` it will just return a `%writ` like:
336336
@@ -357,7 +357,7 @@ If the `track` is `%.n`, the `cage` of the `%writ` will contain a `nako`, which
357357 == ::
358358```
359359
360−As the comment explains, it contains all relevant data for a changes to a desk between what you have and the case requested. It is very large and fairly complicated. The `nako` structure is defined in the `clay.hoon` source file itself rather than in `lull.hoon` or elsewhere since you're unlikely to work with it yourself.
360+As the comment explains, it contains all relevant data for a changes to a desk between what you have and the `case` requested. It is very large and fairly complicated. The `nako` structure is defined in the `clay.hoon` source file itself rather than in `lull.hoon` or elsewhere since you're unlikely to work with it yourself.
361361
362362The `moat` in the `%many` is the following structure:
363363
@@ -365,11 +365,11 @@ The `moat` in the `%many` is the following structure:
365365 +$ moat [from=case to=case =path] :: change range
366366```
367367
368−The `from` and `to` fields specify the range of cases for which to subscribe. The range is *inclusive*. It can be specified by date or by revision number, whichever you prefer.
368+The `from` and `to` fields specify the range of `case`s for which to subscribe. The range is *inclusive*. It can be specified by date or by revision number, whichever you prefer.
369369
370−The `path` is a path to a file or directory. If it's `~` it refers to the root of the desk in question. This lets you say "only inform me of changes to the desk if the specified file or directory exists". If it doesn't exist, clay will send you nothing.
370+The `path` is a path to a file or directory. If it's `~` it refers to the root of the `desk` in question. This lets you say "only inform me of changes to the `desk` if the specified file or directory exists". If it doesn't exist, Clay will not send you anything.
371371
372−When you reach the end of the subscribed range of cases, clay will send you a `%writ` with a null `riot` to inform you the subscription has ended like:
372+When you reach the end of the subscribed range of `case`s, Clay will send you a `%writ` with a null `riot` to inform you the subscription has ended like:
373373
374374```hoon
375375[%writ p=~]
@@ -377,7 +377,7 @@ When you reach the end of the subscribed range of cases, clay will send you a `%
377377
378378Example:
379379
380−This thread will subscribe to changes to your `%home` desk for the next three minutes. The `track` is `%.y` so it will only inform you of changes, not send the full `nako`. It will only get updates if the specified file exists. It contains a `main-loop` that will take an arbitrary number of signs and print them out in the dojo. Since it never ends, you'll need to stop it with the `:spider|kill` command in the dojo.
380+This thread will subscribe to changes to your `%home` `desk` for the next three minutes. The `track` is `%.y` so it will only inform you of changes, not send the full `nako`. It will only get updates if the specified file exists. It contains a `main-loop` that will take an arbitrary number of `sign`s and print them out in the dojo. Since it never ends, you'll need to stop it with the `:spider|kill` command in the dojo.
381381
382382`sub-many.hoon`
383383
@@ -415,7 +415,7 @@ This thread will subscribe to changes to your `%home` desk for the next three mi
415415(pure:m !>(~))
416416```
417417
418−Make sure `foo.txt` doesn't exist in the root of your `%home` desk. Save this to `ted/sub-many.hoon`, `|commit %home`, run it like `-sub-many /foo/txt`, and hit backspace in the dojo to free up the dojo prompt. Now, add a file called `bar.txt` to your desk and `|commit %home`. You should see something like:
418+Make sure `foo.txt` doesn't exist in the root of your `%home` `desk`. Save this to `ted/sub-many.hoon`, `|commit %home`, run it like `-sub-many /foo/txt`, and hit backspace in the dojo to free up the dojo prompt. Now, add a file called `bar.txt` to your `desk` and `|commit %home`. You should see something like:
419419
420420```hoon
421421> |commit %home
@@ -423,7 +423,7 @@ Make sure `foo.txt` doesn't exist in the root of your `%home` desk. Save this to
423423+ /~zod/home/260/bar/txt
424424```
425425
426−Notice you've received no `%writ` from clay. This is because `/foo/txt` doesn't exist. Now, create `foo.txt` and `|commit %home` again. You should see:
426+Notice you've received no `%writ` from Clay. This is because `/foo/txt` doesn't exist. Now, create `foo.txt` and `|commit %home` again. You should see:
427427
428428```hoon
429429> |commit %home
@@ -459,7 +459,7 @@ Now wait until the three minutes is up and try making a change, for example dele
459459- /~zod/home/263/baz/txt
460460```
461461
462−You can see that along with the normal `%writ` it's also sent a second `%writ` with a null `riot` to indicate the subscription has ended. This is because it has now passed the end of the range of cases to which you subscribed.
462+You can see that along with the normal `%writ` it's also sent a second `%writ` with a null `riot` to indicate the subscription has ended. This is because it has now passed the end of the range of `case`s to which you subscribed.
463463
464464Run `:spider|kill` to stop the thread.
465465
@@ -497,7 +497,7 @@ This thread will subscribe to the `%next` version of `/foo/txt`, then immediatel
497497(pure:m !>(~))
498498```
499499
500−Save the above to `ted/stop-sub.hoon`, `|commit %home`, run it with `-stop-sub` and hit backspace to detach it from the dojo prompt. Now, add `foo.txt` to the root of your `%home` desk and `|commit %home`. You should see:
500+Save the above to `ted/stop-sub.hoon`, `|commit %home`, run it with `-stop-sub` and hit backspace to detach it from the dojo prompt. Now, add `foo.txt` to the root of your `%home` `desk` and `|commit %home`. You should see:
501501
502502```hoon
503503> |commit %home
@@ -509,6 +509,6 @@ As you can see we've received no `%writ`. We can thus conclude the subscription
509509
510510Run `:spider|kill` to stop the thread.
511511
512−Here's a breakdown of the task we sent:
512+Here's a breakdown of the `task` we sent:
513513
514514