Skip to content

Commit

Permalink
Allow EXCEPTION effect in updates
Browse files Browse the repository at this point in the history
  • Loading branch information
garyb committed Jul 19, 2016
1 parent 316ce5a commit f542c10
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/Pux.purs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module Pux
) where

import Control.Monad.Aff (Aff, launchAff, later)
import Control.Monad.Aff.Unsafe (unsafeInterleaveAff)
import Control.Monad.Eff (Eff)
import Control.Monad.Eff.Class (liftEff)
import Control.Monad.Eff.Exception (EXCEPTION)
Expand Down Expand Up @@ -59,7 +60,7 @@ start config = do
stateSignal = effModelSignal ~> _.state
htmlSignal = stateSignal ~> \state ->
(runFn3 render) (send actionChannel <<< singleton) (\a -> a) (config.view state)
mapAffect affect = launchAff $ do
mapAffect affect = launchAff $ unsafeInterleaveAff do
action <- later affect
liftEff $ send actionChannel (singleton action)
effectsSignal = effModelSignal ~> map mapAffect <<< _.effects
Expand Down Expand Up @@ -114,7 +115,7 @@ type Update state action eff = action -> state -> EffModel state action eff
-- | effects which return an action.
type EffModel state action eff =
{ state :: state
, effects :: Array (Aff (channel :: CHANNEL | eff) action) }
, effects :: Array (Aff (CoreEffects eff) action) }

-- | Create an `Update` function from a simple step function.
fromSimple :: forall s a eff. (a -> s -> s) -> Update s a eff
Expand All @@ -125,7 +126,7 @@ noEffects :: forall state action eff. state -> EffModel state action eff
noEffects state = { state: state, effects: [] }

onlyEffects :: forall state action eff.
state -> Array (Aff (channel :: CHANNEL | eff) action) -> EffModel state action eff
state -> Array (Aff (CoreEffects eff) action) -> EffModel state action eff
onlyEffects state effects = { state: state, effects: effects }

-- | Map over the state of an `EffModel`.
Expand Down

0 comments on commit f542c10

Please sign in to comment.