yesod-eventsource 1.4.1 → 1.6.0
raw patch · 3 files changed
+25/−18 lines, 3 filesdep ~conduitdep ~yesod-corePVP ok
version bump matches the API change (PVP)
Dependency ranges changed: conduit, yesod-core
API changes (from Hackage documentation)
- Yesod.EventSource: ioToRepEventSource :: s -> (EventSourcePolyfill -> s -> IO ([ServerEvent], s)) -> HandlerT site IO TypedContent
+ Yesod.EventSource: ioToRepEventSource :: s -> (EventSourcePolyfill -> s -> IO ([ServerEvent], s)) -> HandlerFor site TypedContent
- Yesod.EventSource: pollingEventSource :: s -> (EventSourcePolyfill -> s -> HandlerT site IO ([ServerEvent], s)) -> HandlerT site IO TypedContent
+ Yesod.EventSource: pollingEventSource :: s -> (EventSourcePolyfill -> s -> HandlerFor site ([ServerEvent], s)) -> HandlerFor site TypedContent
- Yesod.EventSource: repEventSource :: (EventSourcePolyfill -> Source (HandlerT site IO) ServerEvent) -> HandlerT site IO TypedContent
+ Yesod.EventSource: repEventSource :: (EventSourcePolyfill -> ConduitT () ServerEvent (HandlerFor site) ()) -> HandlerFor site TypedContent
Files
- ChangeLog.md +4/−0
- Yesod/EventSource.hs +18/−15
- yesod-eventsource.cabal +3/−3
ChangeLog.md view
@@ -1,3 +1,7 @@+## 1.6.0++* Upgrade to yesod-core 1.6.0+ ## 1.4.1 * Fix warnings
Yesod/EventSource.hs view
@@ -13,7 +13,7 @@ import Data.Functor ((<$>)) import Data.Monoid (Monoid (..)) import Yesod.Core-import qualified Data.Conduit as C+import Data.Conduit import qualified Network.Wai as W import qualified Network.Wai.EventSource as ES import qualified Network.Wai.EventSource.EventStream as ES@@ -32,32 +32,35 @@ -- | (Internal) Source with a event stream content-type.-respondEventStream :: C.Source (HandlerT site IO) (C.Flush Builder)- -> HandlerT site IO TypedContent+respondEventStream :: ConduitT () (Flush Builder) (HandlerFor site) ()+ -> HandlerFor site TypedContent respondEventStream = respondSource "text/event-stream" --- | Returns a Server-Sent Event stream from a 'C.Source' of+-- | Returns a Server-Sent Event stream from a 'Source' of -- 'ES.ServerEvent'@s@. The HTTP socket is flushed after every--- event. The connection is closed either when the 'C.Source'+-- event. The connection is closed either when the 'Source' -- finishes outputting data or a 'ES.CloseEvent' is outputted, -- whichever comes first.-repEventSource :: (EventSourcePolyfill -> C.Source (HandlerT site IO) ES.ServerEvent)- -> HandlerT site IO TypedContent+repEventSource :: (EventSourcePolyfill -> ConduitT () ES.ServerEvent (HandlerFor site) ())+ -> HandlerFor site TypedContent repEventSource src = prepareForEventSource >>= respondEventStream . sourceToSource . src -- | Convert a ServerEvent source into a Builder source of serialized -- events.-sourceToSource :: Monad m => C.Source m ES.ServerEvent -> C.Source m (C.Flush Builder)+sourceToSource+ :: Monad m+ => ConduitT () ES.ServerEvent m ()+ -> ConduitT () (Flush Builder) m () sourceToSource src =- src C.$= C.awaitForever eventToFlushBuilder+ src .| awaitForever eventToFlushBuilder where eventToFlushBuilder event = case ES.eventToBuilder event of Nothing -> return ()- Just x -> C.yield (C.Chunk x) >> C.yield C.Flush+ Just x -> yield (Chunk x) >> yield Flush -- | Return a Server-Sent Event stream given a 'HandlerT' action@@ -68,8 +71,8 @@ -- The connection is closed as soon as an 'ES.CloseEvent' is -- outputted, after which no other events are sent to the client. pollingEventSource :: s- -> (EventSourcePolyfill -> s -> HandlerT site IO ([ES.ServerEvent], s))- -> HandlerT site IO TypedContent+ -> (EventSourcePolyfill -> s -> HandlerFor site ([ES.ServerEvent], s))+ -> HandlerFor site TypedContent pollingEventSource initial act = do polyfill <- prepareForEventSource let -- Get new events to be sent.@@ -79,8 +82,8 @@ [] -> getEvents s' _ -> do let (builder, continue) = joinEvents evs mempty- C.yield (C.Chunk builder)- C.yield C.Flush+ yield (Chunk builder)+ yield Flush when continue (getEvents s') -- Join all events in a single Builder. Returns @False@@@ -103,7 +106,7 @@ -- outputted, after which no other events are sent to the client. ioToRepEventSource :: s -> (EventSourcePolyfill -> s -> IO ([ES.ServerEvent], s))- -> HandlerT site IO TypedContent+ -> HandlerFor site TypedContent ioToRepEventSource initial act = pollingEventSource initial act' where act' p s = liftIO (act p s)
yesod-eventsource.cabal view
@@ -1,5 +1,5 @@ name: yesod-eventsource-version: 1.4.1+version: 1.6.0 license: MIT license-file: LICENSE author: Felipe Lessa <felipe.lessa@gmail.com>@@ -15,8 +15,8 @@ library build-depends: base >= 4 && < 5- , yesod-core == 1.4.*- , conduit >= 0.5 && < 1.3+ , yesod-core == 1.6.*+ , conduit >= 1.3 , wai >= 1.3 , wai-eventsource >= 1.3 , wai-extra