PlayFramework 2.0.x - > 2.1-RC迁移

non*_*com 5 playframework playframework-2.0 playframework-2.1

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

val channel = Enumerator.imperative[JsValue](onStart = self ! NotifyJoin(username))
Run Code Online (Sandbox Code Playgroud)

现在它说imperative已经弃用了,API说我应该使用unicastbroadcast代替.我倾向于使用,unicast因为在我的代码中channel是单播.所以我喜欢

val channel = Concurrent.unicast[JsValue](onStart = self ! NotifyJoin(username))
Run Code Online (Sandbox Code Playgroud)

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

更新:

在Play Framework用户组中开始讨论.事实证明,对于那些了解范式的开发人员来说,这是一个非常普遍的问题.希望文档能够得到改进.

Jam*_*ard 3

其APIConcurrent.unicast是:

\n\n
unicast[E](onStart: (Channel[E]) \xe2\x87\x92 Unit, onComplete: \xe2\x87\x92 Unit, onError: (String, Input[E]) \xe2\x87\x92 Unit): Enumerator[E]\n
Run Code Online (Sandbox Code Playgroud)\n\n

其APIConcurrent.broadcast是:

\n\n
broadcast[E]: (Enumerator[E], Channel[E])\n
Run Code Online (Sandbox Code Playgroud)\n\n

您可以通过以下位置访问应用程序中的 API:

\n\n
http://localhost:9000/@documentation/api/scala/index.html#play.api.libs.iteratee.Concurrent$\n
Run Code Online (Sandbox Code Playgroud)\n

  • 是的,我在网站上看到了这个。太糟糕了,它没有说明我从哪里获得“Channel[E]”或“Enumerator[E]”,也没有真正解释它是如何工作的。其实我当时在API页面就只有这两个签名。但这并不比 Eclipse 在其自动完成建议中默认提供的帮助多多少。我只是想表明一些解释是值得的。 (2认同)