Skip to content
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

Closed
tunnckoCore opened this issue Feb 7, 2017 · 13 comments
Closed

Force model to be object and always be immutable? #50

tunnckoCore opened this issue Feb 7, 2017 · 13 comments

Comments

@tunnckoCore
Copy link

@jbucaran what you think about the model to be object and freeze it, using Object.freeze or deep-freeze?

@jorgebucaran
Copy link
Owner

@tunnckoCore What's the advantage?

@jorgebucaran
Copy link
Owner

what you think about the model to be object

choo does this IIRC. HyperApp is more flexible allowing the model to be a string, number, array or object.

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 7, 2017

choo does this IIRC

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.

@jorgebucaran
Copy link
Owner

jorgebucaran commented Feb 7, 2017

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.

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 7, 2017

Can you freeze a number or an array or is it limited to objects?

No. In ES2015 it will return it, in below versions it will throw TypeError.

What about simply not changing the model?

For same reason that most devs use flow/typescript - guarantees, I kinda still don't like them, as I don't like the native assert and massive usage of it then "unassertifyfyfyfyfyf" (like Yosh and browserify & co devs does and promotes).

offtopic / 2c

edit: 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 choo and won't use anything from that part of the community.

edit3: And that's the reason why I like hyperapp and that it is really 1-2kb with everything, not like choo which is "5kb", but browserify-ied (big bundles) and unassertify-ied (bad prod. experience)

@jorgebucaran
Copy link
Owner

jorgebucaran commented Feb 7, 2017

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.

@tunnckoCore
Copy link
Author

tunnckoCore commented Feb 7, 2017

but let's not derail this thread or any other to criticize choo. choo was a big source of inspiration for HyperApp.

Yea, it is great in anyway, I just sharing my view points. :)

@jorgebucaran
Copy link
Owner

@tunnckoCore Feel like we can close this?

@tunnckoCore
Copy link
Author

yea, it is clear :)

@okwolf
Copy link
Contributor

okwolf commented Aug 28, 2017

There's a mixin solution for this: https://github.com/okwolf/hyperapp-freeze

@tunnckoCore
Copy link
Author

@okwolf that's cool idea, but any reasonable and logical reason to hardcode the deep-freeze package instead of including it as normally and expose cjs, es and umd bundles (with rollup for example, it's pretty easy)?

@jorgebucaran
Copy link
Owner

jorgebucaran commented Aug 28, 2017

@charlike Yeah, I think he was in a hurry.

@okwolf This should be good to get you started.

Same cosmetic changes apply to hyperapp-freeze, etc. 👋

@okwolf
Copy link
Contributor

okwolf commented Aug 28, 2017

@charlike yes @jbucaran is correct, hyperapp-freeze will get cleaned up after the hyperapp-logger refactor is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants