PlayFramework 2.0.x -> 2.1-RC 迁移

标签 playframework playframework-2.0 playframework-2.1

在我的 Play 2.0.4 程序中,我有这段代码:

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

现在它说 imperative已弃用,API 说我应该使用 unicastbroadcast反而。我倾向于使用 unicast因为在我的代码中 channel是单播的。所以我喜欢
val channel = Concurrent.unicast[JsValue](onStart = self ! NotifyJoin(username))

但它不起作用..看起来像unicast想要别的东西。我无法弄清楚 - API 中没有更多信息......有谁知道在这里做什么?

更新:

在 Play Framework 用户组中开始讨论。事实证明,在熟悉范式的开发人员中,这是一个非常普遍的问题。希望文档能得到改进。

最佳答案

Concurrent.unicast 的 API是:

unicast[E](onStart: (Channel[E]) ⇒ Unit, onComplete: ⇒ Unit, onError: (String, Input[E]) ⇒ Unit): Enumerator[E]
Concurrent.broadcast 的 API是:
broadcast[E]: (Enumerator[E], Channel[E])

您可以通过以下网址访问应用程序中的 API:
http://localhost:9000/@documentation/api/scala/index.html#play.api.libs.iteratee.Concurrent$

关于PlayFramework 2.0.x -> 2.1-RC 迁移,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14141408/

相关文章:

Java/JPA - 动态设置对象/实体的属性

java - GCM - 6 次尝试后无法将 JSON 请求发布到 GCM

Scala Play 和多项目 SBT 构建

Eclipse 与 Play Framework 无法解析的符号

playframework-2.1 - 性能问题 - 编译过程缓慢

scala - Play Famework 2.1 Websockets 是否有 Comet 适配器?

Scala迭代写入文件

java - 无法连接到 grpc 服务器并获取 'First received frame was not SETTINGS'

java - play framework接收paypal IPN请求