Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlayFramework 2.0.x -> 2.1-RC migration

In my program on Play 2.0.4 I had this piece of code:

val channel = Enumerator.imperative[JsValue](onStart = self ! NotifyJoin(username))

and now it says that imperative is deprecated, and the API says that I should use unicast or broadcast instead. I tend to use unicast since in my code the channel was unicast. So I make like

val channel = Concurrent.unicast[JsValue](onStart = self ! NotifyJoin(username))

But it does not work.. looks like that unicast wants something else. I cannot figure it out - there is no more info in the API... does anyone know what to do here?

UPDATE:

Started a discussion in Play Framework user group. Turns out to be a pretty common problem among developers, who are knew to the paradigm. Will hope the documentation is going to be improved.

like image 370
noncom Avatar asked Oct 22 '22 20:10

noncom


1 Answers

The API for Concurrent.unicast is:

unicast[E](onStart: (Channel[E]) ⇒ Unit, onComplete: ⇒ Unit, onError: (String, Input[E]) ⇒ Unit): Enumerator[E]

The API for Concurrent.broadcast is:

broadcast[E]: (Enumerator[E], Channel[E])

You can get to the API in your app at:

http://localhost:9000/@documentation/api/scala/index.html#play.api.libs.iteratee.Concurrent$
like image 86
James Ward Avatar answered Oct 25 '22 20:10

James Ward