yesod-eventsource 1.0 → 1.0.0.1
raw patch · 2 files changed
+15/−12 lines, 2 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- Yesod/EventSource.hs +13/−10
- yesod-eventsource.cabal +2/−2
Yesod/EventSource.hs view
@@ -12,7 +12,7 @@ import Control.Monad (when) import Control.Monad.IO.Class (liftIO) import Data.Functor ((<$>))-import Data.Monoid (mconcat)+import Data.Monoid (mappend, mempty) import Yesod.Content import Yesod.Core import qualified Data.Conduit as C@@ -22,8 +22,8 @@ --- | Phantom type used for 'Handler'@s@ that are @EventSources@--- (e.g. 'repEventSource' and 'ioToRepEventSource').+-- | Data type representing a response of server-sent events+-- (e.g., see 'repEventSource' and 'ioToRepEventSource'). newtype RepEventSource = RepEventSource (C.Source (C.ResourceT IO) (C.Flush Builder)) @@ -54,7 +54,7 @@ -- | Return a Server-Sent Event stream given an @IO@ action that--- is repeatedly called. An state is threaded for the action so+-- is repeatedly called. A state is threaded for the action so -- that it may avoid using @IORefs@. The @IO@ action may sleep -- or block while waiting for more data. The HTTP socket is -- flushed after every list of simultaneous events. The@@ -68,18 +68,21 @@ let -- Get new events to be sent. getEvents s = do (evs, s') <- liftIO (act polyfill s)- let (builder, continue) = joinEvents evs []- C.yield (C.Chunk builder)- C.yield C.Flush- when continue (getEvents s')+ case evs of+ [] -> getEvents s'+ _ -> do+ let (builder, continue) = joinEvents evs mempty+ C.yield (C.Chunk builder)+ C.yield C.Flush+ when continue (getEvents s') -- Join all events in a single Builder. Returns @False@ -- when we the connection should be closed. joinEvents (ev:evs) acc = case ES.eventToBuilder ev of- Just b -> joinEvents evs (b:acc)+ Just b -> joinEvents evs (acc `mappend` b) Nothing -> (fst $ joinEvents [] acc, False)- joinEvents [] acc = (mconcat (reverse acc), True)+ joinEvents [] acc = (acc, True) return $ RepEventSource $ getEvents initial
yesod-eventsource.cabal view
@@ -1,5 +1,5 @@ name: yesod-eventsource-version: 1.0+version: 1.0.0.1 license: MIT license-file: LICENSE author: Felipe Lessa <felipe.lessa@gmail.com>@@ -21,7 +21,7 @@ This package allows your Yesod application to easily send server-sent events. On the client side, you may use the @EventSource@ JavaScript object on browsers that support it- (https://developer.mozilla.org/en-US/docs/Server-sent_events/EventSource)+ (<https://developer.mozilla.org/en-US/docs/Server-sent_events/EventSource>) or a polyfill for browsers that don't (we support Remy's polyfill out-of-the-box, although that requires you to explicitly support it).