Skip to content

Update the book tutorial to use async_std channels #398

Open
@yoshuawuyts

Description

@yoshuawuyts

With #380 landed, we should update the tutorial to use them. This would remove the final dependency on futures-rs (and importantly: Sink) which should be a big step up in terms of usability.

Also we should consider moving from select! {} to Stream::merge. From chat with @skade we've figured out how to "send a close message after a stream has been exhausted":

enum EventKind {
    Event(/* event_type */),
    Shutdown,
}

let events = events.map(|ev| EventKind::Event(ev)).join(stream::once(EventKind::Shutdown));
let shutdown = shutdown.map(|e| EventKind::Event(e));
let s = events.merge(shutdown);

while let Some(event) = s.next().await {
    match event {
        EventKind::Event(ev) => /* handle event */,
        EventKind::Shutdown => /* handle shutdown */,
    }
}

@skade I'm assigning this to you as you've been working on updating this recently. Feel free to unassign yourself if you don't think you'll have bandwidth. Thanks!

edit: this would resolve #105 and #13

Metadata

Metadata

Assignees

Labels

documentationImprovements or additions to documentation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions