Comet
Helper function to produce a Comet using Pekko Streams.
Please see https://en.wikipedia.org/wiki/Comet_(programming) for details of Comet.
Example:
def streamClock() = Action {
val df: DateTimeFormatter = DateTimeFormatter.ofPattern("HH mm ss")
val tickSource = Source.tick(0 millis, 100 millis, "TICK")
val source = tickSource.map((tick) => df.format(ZonedDateTime.now()))
Ok.chunked(source via Comet.flow("parent.clockChanged"))
}
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Comet.type
Members list
Value members
Concrete methods
Creates a flow of ByteString. Useful when you have objects that are not JSON or String where you may have to do your own conversion.
Creates a flow of ByteString. Useful when you have objects that are not JSON or String where you may have to do your own conversion.
Usage example:
val htmlStream: Source[ByteString, ByteString, NotUsed] = Flow[Html].map { html =>
ByteString.fromString(html.toString())
}
...
Ok.chunked(htmlStream via Comet.flow("parent.clockChanged"))
Attributes
Creates a flow of ByteString. Useful when you have objects that are not JSON or String where you may have to do your own conversion.
Creates a flow of ByteString. Useful when you have objects that are not JSON or String where you may have to do your own conversion.
Usage example:
val htmlStream: Source[ByteString, ByteString, NotUsed] = Flow[Html].map { html =>
ByteString.fromString(html.toString())
}
...
Ok.chunked(htmlStream via Comet.flow("parent.clockChanged"))
Attributes
Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue. Calls out to Comet.flow internally.
Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue. Calls out to Comet.flow internally.
Value parameters
- callbackName
-
the javascript callback method.
Attributes
- Returns
-
a flow of ByteString elements.
Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue. Calls out to Comet.flow internally.
Produces a flow of ByteString using Json.fromJson(_).get from a Flow of JsValue. Calls out to Comet.flow internally.
Value parameters
- callbackName
-
the javascript callback method.
- nonce
-
The CSP nonce to use for the script tag. If null no nonce will be sent.
Attributes
- Returns
-
a flow of ByteString elements.
Produces a Flow of escaped ByteString from a series of String elements. Calls out to Comet.flow internally.
Produces a Flow of escaped ByteString from a series of String elements. Calls out to Comet.flow internally.
Value parameters
- callbackName
-
the javascript callback method.
Attributes
- Returns
-
a flow of ByteString elements.
Produces a Flow of escaped ByteString from a series of String elements. Calls out to Comet.flow internally.
Produces a Flow of escaped ByteString from a series of String elements. Calls out to Comet.flow internally.
Value parameters
- callbackName
-
the javascript callback method.
- nonce
-
The CSP nonce to use for the script tag. If null no nonce will be sent.
Attributes
- Returns
-
a flow of ByteString elements.