class CallableFunction(name:String, callback:(String)=>JsCmd, args:List[String] = List()) extends JsCmd {
override val toJsCmd =
Function(
name, args,
ajaxCall(JsRaw("Array.prototype.slice.call(arguments).join('|')"), callback)._2
).toJsCmd
}
You can then create an arbitrary function:
case class UpdateClosed(callback:(String)=>JsCmd) extends CallableFunction("updateClosed", callback, List("id"))
Above, your Script would then just hold Script(SortableUpdateServerCallback( ... )). Just a tad bit of abstraction.
We typically serve these out in the render segment of a Comet, and they invoke a comet function that sends the CometActor a message to handle the relevant action.
We also have a:
class AnonCallableFunction(callback:(String)=>JsCmd, args:List[String] = List()) extends JsCmd {
override val toJsCmd =
AnonFunc(
args.mkString(","),
ajaxCall(JsRaw("Array.prototype.slice.call(arguments).join('|')"), callback)._2
).toJsCmd
}
It's used for when we send down JSON with callbacks.
Thanks,
Antonio