Decide on approach to immutabilty enforcement for redux store

CSP Request Details

None

CSP Rejection Details

None

CSP Approved

None

Description

Redux requires that reducers not mutate the state object in any way. Object.freeze() only works at the top level so there are a large variety of utilities to enable deeper protection. They can also offer some performance improvements based on their immutability guarantees.

The most commonly adopted implementation (and the one endorsed at the talk I went to last week) is ImmutableJS by Facebook. However, it doesn't actually guarantee immutability:

https://github.com/facebook/immutable-js/issues/546

And the syntax is... weird. Very many of the React related tools have special support for it. But perhaps not everything we may one day want to use. There are several alternatives, one that I'm leaning towards is seamless-immutable, they make a good case for it here:

http://tech.noredink.com/post/107617838018/switching-from-immutablejs-to-seamless-immutable

But it seems like that company is moving to use Elm for everything rather than Javascript so I wonder how well it will be maintained going forward? OTOH, not exactly an OS, fairly simple thing and has enough traction that it probably is okay?

https://github.com/rtfeldman/seamless-immutable
http://tech.noredink.com/post/136615783598/welcome-evan

At the moment I'm playing with it on the experiments repo as that's what the redux-crud package uses for its reducers. However it's very likely we'll reimplement that for OKAPI-specific crud anyway (OLE-89)

Environment

None

Potential Workaround

None

Checklist

hide

TestRail: Results

Activity

Show:

Jason SkomorowskiDecember 9, 2016 at 9:50 PM

We decided to not use Immutable.js as we didn't want to require module developers to learn that API and so instead will be limited to Object.freeze() which we might just run in dev mode and turn off for production. See .

Jason SkomorowskiMarch 31, 2016 at 11:44 PM
Edited

Notes from Rangle:

  • immutable-repl is a good tool for playing with immutable

  • probably shouldn't have to expose any immutable stuff to the stripes-modules, we can just Object.seal/Object.freeze the props we pass in

Jason SkomorowskiFebruary 4, 2016 at 5:12 AM
Edited

seamless-immutable has some issues with redux-form or... something. At least, I found it suddenly choking when redux-crud employed it even in our small app and the only reducers were from redux-crud, redux-form and react-router-redux. Someone else hit it with form:
https://github.com/glittershark/reactable/issues/220

Went away when I configured redux-crud to use plain objects (after I first tried to initialise the redux store with an explicitly created empty seamless-immutable object). And I'm inclined to use redux-form. And it has ImmutableJS support.

Perhaps that is enough to make our decision on right there?

Done

Details

Assignee

Reporter

Priority

TestRail: Cases

Open TestRail: Cases

TestRail: Runs

Open TestRail: Runs

Created January 18, 2016 at 6:39 AM
Updated March 2, 2017 at 1:41 PM
Resolved December 9, 2016 at 9:50 PM
Loading...