Closed arv closed 11 months ago
This got a lot more complicated than I like.
PS I've been thinking about https://github.com/rocicorp/replicache-react/pull/59/files#diff-a2a171449d862fe29692ce031981047d7ab755ae7f84c707aef80701b3ea0c80R122. I think we should make this API officially and document that query
and opts
are not reactive and do not cause useSubscribe
to re-run.
If users wants these values to be reactive they can pass some deps instead that encapsulate the change that happened.
My reasoning is that users ~never want these values reactive, as evidenced by the fact that nobody has ever complained about the fact that they are not.
BREAKING CHANGE!
useSubscribe
now allows passing anisEqual
function that is used to compare the new returned value from the query with the last value. This requires Replicache 14 or a Reflect release containing acefbcefff649eed8adf5f06de345fee4f74f66c (at the time of writing no such release existed).The new API now takes an optional
option
object:This allows the query function to return non JSON values.
Note: If used with Replicache 13, the
isEqual
option is ignored which can be confusing.Note 2: If
isEqual
is omitted a deep JSON equality check is used which means that things likenew Set([1])
andnew Set([2])
are considered equal. Be careful!