Module
Impulse.DOM
- Package
- purescript-impulse
- Repository
- mitchdzugan/purescript-impulse
Re-exports from Impulse.DOM.API
#ImpulseStash Source
data ImpulseStash :: Type -> Type
#ImpulseSSR Source
data ImpulseSSR :: Type -> Type
#ImpulseAttachment Source
data ImpulseAttachment :: Type -> Type
#withAlteredEnv Source
withAlteredEnv :: forall a c e2 e1. (e1 -> e2) -> DOM e2 c a -> DOM e1 c a
#stashRes Source
stashRes :: forall a. ImpulseStash a -> a
#d_stash Source
d_stash :: forall a c e. DOM e c a -> DOM e c (ImpulseStash a)
d_stash inner
runs inner
but does not render in place, instead stashes whatever
was rendered such that it can be used later using d_apply
.
stashes are immutable and can be passed around as far as you like.
test :: forall e c. DOM e c Unit
test = do
ul_ anil do
stash <- d_stash do
li_ anil $ text "out"
li_ anil $ text "of"
li_ anil $ text "order?"
li_ anil $ text "You"
li_ anil $ text "thought"
li_ anil $ text "this"
li_ anil $ text "was"
d_apply stash
results in
<ul>
<li>You</li>
<li>thought</li>
<li>this</li>
<li>was</li>
<li>out</li>
<li>of</li>
<li>order?</li>
</ul>
#d_apply Source
d_apply :: forall a c e. ImpulseStash a -> DOM e c a
#attachRes Source
attachRes :: forall a. ImpulseAttachment a -> a
Re-exports from Impulse.DOM.Attrs
#attr_value Source
attr_value :: String -> Attrs
Re-exports from Impulse.DOM.ImpulseEl
#WebEventable Source
#withStopPropagation Source
withStopPropagation :: forall e. WebEventable e => Event e -> Event e
#withPreventDefault Source
withPreventDefault :: forall e. WebEventable e => Event e -> Event e
#onMouseOver Source
onMouseOver :: forall a. ImpulseEl a -> Event MouseEvent
#onMouseOut Source
onMouseOut :: forall a. ImpulseEl a -> Event MouseEvent
#onMouseMove Source
onMouseMove :: forall a. ImpulseEl a -> Event MouseEvent
#onMouseLeave Source
onMouseLeave :: forall a. ImpulseEl a -> Event MouseEvent
#onMouseEnter Source
onMouseEnter :: forall a. ImpulseEl a -> Event MouseEvent
#onMouseDown Source
onMouseDown :: forall a. ImpulseEl a -> Event MouseEvent
#onKeyPress Source
onKeyPress :: forall a. ImpulseEl a -> Event KeyboardEvent
#onDoubleClick Source
onDoubleClick :: forall a. ImpulseEl a -> Event MouseEvent
#d_m_value_e Source
d_m_value_e :: forall e. WebEventable e => Event e -> Event (Maybe String)
Re-exports from Impulse.DOM.Tags
Re-exports from Impulse.DOM.Util
#upsertEnv Source
upsertEnv :: forall c rOSymless rO rSym rI sym a res. IsSymbol sym => Lacks sym () => Cons sym a () rSym => Cons sym a rOSymless rO => Union rSym rI rO => SProxy sym -> a -> DOM (Record rO) c res -> DOM (Record rI) c res
upsertEnv p value inner
runs inner
with value
added to the environment at p
p_test = (SProxy :: SProxy "test")
displayFromEnv :: forall e c. DOM { test :: String | e } c Unit
displayFromEnv = do
test <- getEnv p_test
div_ anil $ text test
test :: forall e c. DOM e c Unit
test = do
upsertEnv p_test "Hello World!" do -- <-- Usage here
displayFromEnv
results in
<div>Hello World!</div>
#s_extract_ Source
s_extract_ :: forall a c e. Signal (ImpulseStash a) -> DOM e c (ImpulseStash Unit)
#s_extract Source
s_extract :: forall a c e. Signal (ImpulseStash a) -> DOM e c (ImpulseStash (Signal a))
#getEnv Source
getEnv :: forall l r2 r1 a c. IsSymbol l => Cons l a r1 r2 => SProxy l -> DOM (Record r2) c a
getEnv p
pulls the value at p
out of the current environment
p_test = (SProxy :: SProxy "test")
displayFromEnv :: forall e c. DOM { test :: String | e } c Unit
displayFromEnv = do
test <- getEnv p_test -- <-- Usage here
div_ anil $ text test
test :: forall e c. DOM e c Unit
test = do
upsertEnv p_test "Hello World!" do
displayFromEnv
results in
<div>Hello World!</div>
#e_collectAndReduce Source
e_collectAndReduce :: forall cOSymless cO cSym cI eOSymless eO eSym eI sym b a res. IsSymbol sym => Lacks sym () => Cons sym (Collector a) () cSym => Cons sym (Collector a) cOSymless cO => Union cSym cI cO => Cons sym (Signal b) () eSym => Cons sym (Signal b) eOSymless eO => Union eSym eI eO => SProxy sym -> (b -> a -> b) -> b -> DOM (Record eO) (Record cO) res -> DOM (Record eI) (Record cI) res
e_collectAndReduce p reducer init inner
Creates a signal from the supplied reducer
and init
ial value.
inner
is then run with the created signal injected into the
environment at p
. The event used to drive the reducer
is the
combination of all events e_emit
ed to p
while running inner
.
p_score = (SProxy :: SProxy "score")
scoreButton ::
forall e c.
Int ->
String ->
DOM e { score :: Collector Int | c } Unit
scoreButton change message = do
d_button <- button anil $ text message
e_emit p_score $ onClick d_button <#> const change
displayScore ::
forall e c.
DOM { score :: Signal Int | e } c Unit
displayScore = do
s_score <- getEnv p_score
s_bindDOM_ s_score \score -> do
span_ anil $ text $ "Score: " <> show score
test :: forall e c. DOM e c Unit
test = do
e_collectAndReduce p_score (\agg change -> agg + change) 0 do
scoreButton (-1) "Decrement Score"
displayScore
scoreButton (1) "Increment Score"
results in
<button>Decrement Score</button>
<span>Score: 0</span>
<button>Increment Score</button>
with the score text changing as expected
#d_clone Source
d_clone :: forall a c e. ImpulseStash a -> DOM e c (ImpulseStash a)