komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components
http://komponent.io
MIT License
427 stars 31 forks source link

2.0.0.pre.1 #84

Closed florentferry closed 6 years ago

florentferry commented 6 years ago

58, #61, #76, #77, #78, #79, #82

nicolas-brousse commented 6 years ago

@florentferry looks really nice.

I use this branch on my current project, all looks good for me. I didn't test cached: true, but I found something incoherent.

In the readme there is cache_key mentioned (https://github.com/komposable/komponent/pull/84/files#diff-04c6e90faac2675aa89e2176d2eec7d8R139):

+/ or cache the component with a specific key, such as the last update of a model
+= component "button", { text: "Click here" }, cached: true, cache_key: @product.updated_at

But in the renderer, looks like the option is not used (https://github.com/komposable/komponent/pull/84/files#diff-d662fd06dc2cbab92ab384c4af54a041R16). Or may be I simply missed something.

florentferry commented 6 years ago

@nicolas-brousse

Yes, it's up to you to choose the key you want to be the cache key. We use cache_key in our example but any key which change between each rendering should refresh the cache.

nicolas-brousse commented 6 years ago

Ah! yes, because cache_key is in options, so used in the final key generation (key = [component, locals, options, cached_block].to_s).
Sorry then, I read it to quickly.

Nice job!

nicolas-brousse commented 6 years ago

When do you think to merge this PR and release the pre version?

florentferry commented 6 years ago

Current of April, I think. Maybe integrate some others issues into it. But I can release it to prevent to add git key in Gemfile.