https://www.youtube.com/watch?v=nQo0EdHNjto
- reusable components
- props over state
- prop === state => problem!
- stateless components
- easy to unit test
- props over state
- PropTypes are serious
<% flash.each do |type, message| %> | |
<div class="alert <%= bootstrap_class_for(type) %> fade in"> | |
<button class="close" data-dismiss="alert">×</button> | |
<%= message %> | |
</div> | |
<% end %> |
class ArticlesController < ApplicationController | |
before_filter :load_temp_upload, :only => ["create", "update"] | |
def update | |
if params[:ajaxupload] | |
if @article.update_attributes(:picture => params[:article][:picture]) | |
render(:text => {:response => 'success', :url => @article.picture.url(:thumb)}.to_json) | |
else | |
render(:text => {:response => 'failure', :message => @article.errors.full_messages.join('\n')}.to_json) | |
end |
const setJackson = R.pipe( | |
R.prop("users"), | |
R.map( | |
(user) => | |
R.startsWith('J', user.name) | |
? {...user, name: R.concat(user.name, ' Jackson')} | |
: user | |
) | |
) |
const isOld = R.gt(R.__, 33) | |
const getOldPeople = R.pipe( | |
R.prop("users"), | |
R.filter(R.where({age: isOld})) | |
) | |
const getOldPeople = R.pipe( | |
R.prop("users"), | |
R.filter(R.propSatisfies(isOld, 'age')) |
R.pipe( | |
R.prop("users"), | |
R.sortBy(R.prop("age")), | |
R.take(3), | |
R.pluck("name") | |
) |
const myProp = (key, maybeObject) => { | |
if (maybeObject === undefined) { | |
return (object) => { | |
return myProp(key, object) | |
} | |
} | |
return maybeObject[key] | |
} |
const increment = (key, obj) => { | |
return { | |
...obj, | |
[key]: obj[key] + 1 | |
} | |
} |
https://www.youtube.com/watch?v=nQo0EdHNjto
import Html exposing (text) | |
partition n = | |
break (n - 1, 0) | |
break (n, total) = | |
case n of | |
1 -> total + 1 | |
n -> 1 + break(n - 1, total + 1) |
Blazing fast:
emacs --daemon
emacsclient .
inside terminal:
emacsclient -nw .