Skip to content

Stage and ActiveClient ergonomics #3

@3mcd

Description

@3mcd

Getting the ActiveClient instance from a client is a little hairy and error-prone. You have to do stuff like:

if (client.state() === StageState.Ready) {
  client.stage().ready!...
}

Where we have to manually assert the presence of the ready property. We could take advantage of a union type/type narrowing to make this more intuitive and "safer".

Furthermore, getting deeply nested properties off of ActiveClient and company can be really nasty, e.g.

mockClientServer.client1.stage().ready!.timekeepingSimulations.stepper
          .lastReceivedSnapshotTimestamp!

By the looks of it, we didn't port over a few methods that would make this a bit cleaner, like this one from ready.rs:

    pub fn last_received_snapshot_timestamp(&self) -> &Option<Timestamp> {
        &self
            .0
            .borrow()
            .timekeeping_simulations
            .last_received_snapshot_timestamp
    }

The equivalent in snowglobe would let us rewrite the above TypeScript snippet as:

mockClientServer.client1.stage().ready!.lastReceivedSnapshotTimestamp()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions