-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Refactor Response class and add new initialization methods #28
base: main
Are you sure you want to change the base?
Conversation
- Add default response status and status text in the `Response` constructors - Add `Response.jsify` method for initializing `Response` with a JS object as body - Separate `Response.json` method from `Response.jsify` for initializing `Response` with a JSON-encodable object as body - Add documentation for main the constructors of `Response`
@gaetschwartz thanks for this - what's the use case for the |
Well, as |
I'm not really familiar with the project, but it looks alright at a quick glance. I'd still consider this a breaking change (since the "json" constructor changes). |
Co-authored-by: Remi Rousselet <darky12s@gmail.com>
Changes
Response
constructorsResponse.jsify
method for initializingResponse
with a JS object as bodyResponse.json
method fromResponse.jsify
for initializingResponse
with a JSON-encodable object as bodyResponse
Motivation
jsify
is subject to minification and has somewhat bad performance. When usingdart compile
with minification enabled, the response json gets minified (after a certain depth AFAIK). It should not be the case. The newResponse.json
behaves simlarly from the previous implementation except that it doesn't minify as it usesjson.encode
. Renamed the previous implementation toResponse.jsify
as it could still be useful for some cases.