Richard Searle's Blog

Thoughts about software

Surprising difference between Shtml ajaxButton and Shtml ajaxCheckbox

Posted by eggsearle on August 6, 2011

Consider the following code

 def clear = SHtml.ajaxButton("Clear", ()=> {
     this ! Clear

  def checkbox = SHtml.ajaxCheckbox(true, selected => {
    this ! SetScroll(selected)
  }, "id" -> check)

Note the Noop reference at the end of callback function for the ajaxButton to satisfy the signature: ()=>JsCmd

However the signature for the ajaxCheckbox callback is (Boolean) =>JcCmd. However, in this case the compiler accepts Unit as the “return” value.

This implies there is an implicit conversion from Unit to Noop, that is local to ajaxCheckbox!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: