-
Notifications
You must be signed in to change notification settings - Fork 9
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
Add a function to only freeze (if enabled) #16
Comments
Feel free to use DeepFreeze instead... |
I did something like this: import iassign from 'immutable-assign'
import DeepFreeze from 'deep-freeze'
export const deepFreeze = obj => iassign.freeze ? DeepFreeze(obj) : obj Would you be opposed to a PR with such a wrapper included in ImmutableAssign? |
Why create dependency on DeepFreeze, when benefit (freezing is usefull for developer only, in production it is no-no) is so small ? Moreover you can add such trival wrapper to your project as single function without forcing all consumers of iassign to bloat their code with DeepFreeze? |
Now I see that DeepFreeze is in current version required anyway... |
Hi geirsagberg, I am not a fan of re-exporting of another module, which is antipattern. The better way is that you create your own module (called immutable-util for example), which export iassign() and deepFreeze(). And make your application codes depending on the new module, so you can swap out iassign() in the future if needed. |
That's good advice, I might just do that. Thanks!
…On Sat, Aug 12, 2017, 03:55 Paul Li ***@***.***> wrote:
Hi geirsagberg, I am not a fan of re-exporting of another module, which is
antipattern. The better way is that you create your own module (called
immutable-util for example), which export iassign() and deepFreeze(). And
make your application codes depending on the new module, so you can swap
out iassign() in the future if needed.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAkShN8fnRgfQ07RtqPKYQQOTULhgw87ks5sXQX4gaJpZM4O0rvJ>
.
|
When using
seamless-immutable
, I usually doImmutable.from(result)
for all my AJAX-calls, so I am sure it will not be changed further down the line.It would be nice to have a similar function for ImmutableAssign, that would
Object.Freeze
if enabled, otherwise it would do nothing.Example:
const immutableResult = iassign(result)
The text was updated successfully, but these errors were encountered: