snowglobe
snowglobe copied to clipboard
`Stage` and `ActiveClient` ergonomics
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()