Re:Cap'n Web: a new RPC system for browsers and web servers
by kentonv on Tuesday September 23, 2025 @08:54AM
(#45346363)
If you invoke `Date.toLocaleString()` in a map callback, it will consistently always run on the client.
[ Parent
| on HN ]
Re:Cap'n Web: a new RPC system for browsers and web servers
by fizx on Tuesday September 23, 2025 @03:39PM
(#45351765)
I don't see how this very contrived example pipelines:
client.getAll({userIds}).map((user) => user.updatedAt == new Date().toLocaleString() ? client.photosFor(user.id) : {})
or without the conditional, client.getAll({userIds}).map((user) => client.photos({userId: user.id, since: new Date(user.updatedAt).toLocaleString()})
Like it has to call toLocaleString on the server, no?
Re:Cap'n Web: a new RPC system for browsers and web servers
by kentonv on Tuesday September 23, 2025 @09:18PM
(#45355074)
Neither of these will type check.
You can't perform computation on a promise. The only thing you can do is pipeline on it.
`user.updatedAt == date` is trying to compare a promise against a date. It won't type check.
`new Date(user.updatedAt)` is passing a promise to the Date constructor. It won't type check.