Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow EXCEPTION effect in updates #58

Merged
merged 1 commit into from
Jul 20, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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