mirror of
https://github.com/nushell/nushell.git
synced 2025-08-16 14:21:01 +02:00
Add examples for receiving data from a job (#16372)
# Description The existing examples cover how to send data to a job, but I think it will be much more common to want to receive data from a job. # User-Facing Changes Just documentation, though it may be worth highlighting anyway. I really thought for a while that this was not possible yet. See also my book PR https://github.com/nushell/nushell.github.io/pull/2006 (`job send` and `job recv` were not documented in the book at all).
This commit is contained in:
@ -116,6 +116,11 @@ in no particular order, regardless of the specified timeout parameter.
|
||||
description: "Get a message or fail if no message is available immediately",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
example: "job spawn { sleep 1sec; 'hi' | job send 0 }; job recv",
|
||||
description: "Receive a message from a newly-spawned job",
|
||||
result: None,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -101,10 +101,17 @@ This command never blocks.
|
||||
}
|
||||
|
||||
fn examples(&self) -> Vec<Example> {
|
||||
vec![Example {
|
||||
example: "let id = job spawn { job recv | save sent.txt }; 'hi' | job send $id",
|
||||
description: "Send a message to a newly spawned job",
|
||||
result: None,
|
||||
}]
|
||||
vec![
|
||||
Example {
|
||||
example: "let id = job spawn { job recv | save sent.txt }; 'hi' | job send $id",
|
||||
description: "Send a message from the main thread to a newly-spawned job",
|
||||
result: None,
|
||||
},
|
||||
Example {
|
||||
example: "job spawn { sleep 1sec; 'hi' | job send 0 }; job recv",
|
||||
description: "Send a message from a newly-spawned job to the main thread (which always has an ID of 0)",
|
||||
result: None,
|
||||
},
|
||||
]
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user