From a performance stand point -- does it really matter?
You are right. fadeIn and fadeOut should have some optional callback for completion.
You are right. fadeIn and fadeOut should have some optional callback for completion.
zam.fadeIn(el, duration)
.then(zam.ajax(url))
.then(response => response.json())
.then(json => el.innerHTML = json.results[2].message)
This code is nearly self-documenting, is easier for a transpiler to handle, and doesn't scream "refactor me!" right after you've deployed your app.But what is the meaning to add a lambda function as "response => response.json()" in a then? why a different lambda "json => el.innerHTML = json.results[2].message" ?
isn't it a "gratuitous" use of a then-able object? I found more readable to have a (sincronous, debuggable, "old-style") function without the need to split in one thousand one line lambdas.
moreover, my python background makes me looks as "ugly" the last one, as it's a lambda function with an assignement, and not a simple expression.