Closed Bug 1419407 Opened 8 years ago Closed 8 years ago

Remove Immutable usage in prefs reducer

Categories

(DevTools :: Console, enhancement, P3)

enhancement

Tracking

(firefox59 fixed)

RESOLVED FIXED
Firefox 59
Tracking Status
firefox59 --- fixed

People

(Reporter: nchevobbe, Assigned: miller.time.baby, Mentored)

References

(Blocks 1 open bug)

Details

(Keywords: good-first-bug)

Attachments

(1 file)

Immutable is adding some overhead to reducer code, and we can remove it. This bug is about removing it from the prefs reducer : https://searchfox.org/mozilla-central/rev/919dce54f43356c22d6ff6b81c07ef412b1bf933/devtools/client/webconsole/new-console-output/reducers/prefs.js#9 We shouldn't use a Immutable.Record, but a plain object instead. This might change how we get some properties or assertions in tests. Make sure the following command does not return tests failure: `cd devtools/client/webconsole/ && npm install && npm test`
Depends on: 1419410
Mentor: nchevobbe
No longer depends on: 1419405, 1419410
Keywords: good-first-bug
Priority: -- → P3
I'd like to try to work on this bug (my first!).
> We shouldn't use a Immutable.Record, but a plain object instead. I'm curious what the preference would be: an exported constructor to replace the Immutable.Record constructor that's being used -- versus creating PrefState instances elsewhere as simple object literals?
Flags: needinfo?(nchevobbe)
Hello Russel, Thanks for working on this :) So the idea here is to replace the Immutable constructor by a simple function that returns a frozen object : ``` const PrefState = (overrides) => Object.freeze(Object.assign({ logLimit: 1000 }, overrides)); ``` and simply call it from the reducer (state = PrefState()) We freeze it because redux expect us to return a new copy of the state, so we don't want to mutate the old state. If we do so here, freeze will throw, so it kind of protect us. And we do set an `overrides` because we do create the state from the store as well : https://searchfox.org/mozilla-central/rev/33c90c196bc405e628bc868a4f4ba29b992478c0/devtools/client/webconsole/new-console-output/store.js#46 and here we force the logLimit (we use it for some test). So in store js, we only need to get rid of the `new` part.
Flags: needinfo?(nchevobbe)
Assignee: nobody → miller.time.baby
Status: NEW → ASSIGNED
Comment on attachment 8931418 [details] Bug 1419407 - remove Immutable usage in prefs reducer; https://reviewboard.mozilla.org/r/202560/#review207906 ::: commit-message-b6bed:1 (Diff revision 1) > +Bug 1419407 - remove Immutable usage in prefs reducer we miss the `;r=nchevobbe` part here :)
Attachment #8931418 - Flags: review+
Things are looking good :) Let's push to try to see if everything works as expected. In the meantime, can you amend your commit message and push to review again ? Thanks !
Done, sorry wasn't sure who would be reviewing :)
TY is green , let's land this :)
Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/df5b2fa427f7 remove Immutable usage in prefs reducer; r=nchevobbe
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 59
Product: Firefox → DevTools
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: