Do you think it could make sense to add an init function next to get and set?
I just wrote a binding, which needs to hide/ show an element initially. I have a working solution, but I think that putting the code into an init function would be nicer:
ViewModel.addBinding 'slide', ->
firstRun = true
set: ($elem, new_value, args, kwhash) ->
if firstRun
if not new_value and $elem.is ':visible'
console.warn 'To avoid flickering you should use CSS to hide the element', $elem.get(0), 'initially'
$elem.hide()
firstRun = false
if new_value
$elem.slideDown()
else
$elem.slideUp()
Do you think it could make sense to add an
init
function next toget
andset
? I just wrote a binding, which needs to hide/ show an element initially. I have a working solution, but I think that putting the code into aninit
function would be nicer: