Since the JSON payloads can be quite large, using json.decode() on the main thread could cause janking.
One solution would be to expose a method that does the decoding which defaults to json.decode but allow it to be overridden in order to use compute() or any other Isolate method.
Internally, all references in the package to json.decode(response.body) would have to be replaced with something like await algolia.decodeJson(response.body),
Example:
class Algolia {
// ... stuff
/// The method that one can override
FutureOr<dynamic> decodeJson(String payload) => json.decode(payload);
}
This can then be overridden by the user using compute(), for example
Hi,
Since the JSON payloads can be quite large, using
json.decode()
on the main thread could cause janking.One solution would be to expose a method that does the decoding which defaults to
json.decode
but allow it to be overridden in order to usecompute()
or any otherIsolate
method.Internally, all references in the package to
json.decode(response.body)
would have to be replaced with something likeawait algolia.decodeJson(response.body)
,Example:
This can then be overridden by the user using
compute()
, for exampleIf you're happy with this approach, I can write up something and submit a PR.