Section 8 of 25

Data flows

Contents
Querywindowcommands.rsservice.rsstore.rsdtoCommandwindowcommands.rsHandleupdateEffectEventactorSnapshotevents.rsemitwindow

8.1. Query (a read)

window ─invoke─► app/<s>/commands.rs ─► core/<s>/service.rs ─► core/<s>/store.rs
                        ◄── dto.rs ◄──────── model ◄──────────────────┘

A read does not go through an actor, unless it reads that actor's state. Then it reads the latest Snapshot from the Handle, without sending a message.

8.2. Command (a change)

Without background state (saving a setting, creating a file):

window ─invoke─► commands ─► service ─► logic (decision) ─► store / drivers ─► result

With background state (a run, a conversation, a recording):

window ─invoke─► commands ─► Handle.send(Msg)
                                  │
                 actor ◄──────────┘
                   update(&mut State, Msg) -> Vec<Effect>     pure function
                   for e in effects: execute(e)               I/O: drivers, store, timers
                   snapshot.send(State.view())                the window gets a new view

8.3. Event (backend → window)

Events are emitted only from app/<s>/events.rs. A slice in core publishes changes through a watch::Sender<Snapshot> or a broadcast::Sender<Event>. events.rs subscribes and calls emit. This keeps core unaware of the window, and gives the front-end exactly one place where each slice's events come from. Event names follow <slice>:<event>, for example recording:snapshot.

app/src/recording/events.rs:

pub fn spawn(app: AppHandle, recordings: recording::Handle) {
    let mut snapshots = recordings.subscribe();
    tauri::async_runtime::spawn(async move {
        while snapshots.changed().await.is_ok() {
            let view = RecordingsDto::from(&*snapshots.borrow());
            if app.emit("recording:snapshot", view).is_err() {
                break;
            }
        }
    });
}

8.4. High-volume streams

Some slices produce many small events: log lines, transcript words, progress ticks. Do not emit one Tauri event per line. Give the slice a bounded channel in core: a small sender type of the slice's own (for example the WordSink in section 20.3) whose send never waits and returns what happened, such as Sent::Delivered, Sent::Dropped or Sent::Closed. Let app/<s>/events.rs own a pump that batches lines into a tauri::ipc::Channel every few milliseconds. The bounded channel is the back-pressure: when the window is slow, the slice learns it (Sent::Dropped) instead of filling memory, and when nobody listens any more (Sent::Closed) the slice can stop. The batching, the channel and the frame rate are entry concerns and stay in app.