I can make
a very good coffee!
var salary = 1000;
// salary can be null if the user doesn't
// provide it
var salary = null;
// salary can be null if the user doesn't
// provide it
ReactDOM.render(
<span>Your salary : {salary}!</span>,
document.getElementById('root')
);
Your salary: 1000!
Rendering
var salary = 1000;
// salary can be null if the user doesn't
// provide it
ReactDOM.render(
<span>Your salary : {salary}!</span>,
document.getElementById('root')
);
Your salary: !
Rendering
var salary = null;
// salary can be null if the user doesn't
// provide it
ReactDOM.render(
<span>Your salary : {salary}!</span>,
document.getElementById('root')
);
How can I avoid this
kind of bugs?
@sebbes #elmlang
Zero Runtime Exception
Are they wizards??!!
Credits: @JoGrenat
Credits: @JoGrenat
Credits: @JoGrenat
Oh, it looks like
Redux!
type alias Model = { salary : Int }
type Msg = Increment | Decrement
update msg model =
case msg of
Increment ->
{ salary = model.salary + 100 }
Decrement ->
{ salary = model.salary - 100 }
type alias Model = { salary : Int }
type Msg = Increment | Decrement
update msg model =
case msg of
Increment ->
{ salary = model.salary + 100 }
Decrement ->
{ salary = model.salary - 100 }
You don't seem
to update anything!
view model = div [] [
button [onClick Increment] [text "+"],
p [] [text (String.fromInt model.salary)],
button [onClick Decrement] [text "-"]
]
main = sandbox {
init = { salary = 1000},
update = update,
view = view
}
view model = div [] [
button [onClick Increment] [text "+"],
p [] [text (String.fromInt model.salary)],
button [onClick Decrement] [text "-"]
]
main = sandbox {
init = { salary = 1000},
update = update,
view = view
}
I get it: when you click,
it launches the update!
Credits: @JoGrenat
Credits: @JoGrenat
How do you actually
perform side effects?
Credits: @JoGrenat
How do you actually
perform side effects?
Cmd Msg
What about
performances?
elm make --optimize
Functional
programming
Immutability
Tooling
Types
One-way
data flow
Virtual DOM
Performances
Credits: @JoGrenat
What about integration
with existing code base?