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
Force model to be object and always be immutable? #50
Comments
@tunnckoCore What's the advantage? |
choo does this IIRC. HyperApp is more flexible allowing the model to be a string, number, array or object. |
That's why I'm asking. I think it is immutable for reason. And that isn't only in choo, actually. "immutable" and "functional" are kinda trending these days. I'm not so frontend, but I like that and I believe that's good and correct trend. |
Can you freeze a number or an array or is it limited to objects? What about simply not changing the model? The only reason you'd want to freeze the model is to avoid mutations, but you can also avoid this by not mutating the model yourself. |
No. In ES2015 it will return it, in below versions it will throw TypeError.
For same reason that most devs use offtopic / 2cedit: I'm strongly against that massive usage of assert and then unassertify "for production", because it drives you directly to the hell - unexpected errors, throws, awful stacktraces and etc. edit2: Actually, that's the biggest reason that I don't like and don't use edit3: And that's the reason why I like |
Thanks for supporting Hyperapp, I like it too ;) but let's not derail this thread or any other to criticize choo. choo was a big source of inspiration for me. With regards to the issue at hand, I have nothing against object.freeze, but I don't know if it is worth introducing in core. |
Yea, it is great in anyway, I just sharing my view points. :) |
@tunnckoCore Feel like we can close this? |
yea, it is clear :) |
There's a mixin solution for this: https://github.com/okwolf/hyperapp-freeze |
@okwolf that's cool idea, but any reasonable and logical reason to hardcode the |
@jbucaran what you think about the model to be object and freeze it, using
Object.freeze
ordeep-freeze
?The text was updated successfully, but these errors were encountered: