This repository was archived by the owner on Oct 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
Expand file tree
/
Copy pathEventTarget.purs
More file actions
44 lines (38 loc) · 1.34 KB
/
EventTarget.purs
File metadata and controls
44 lines (38 loc) · 1.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
module DOM.Event.EventTarget where
import Prelude
import Control.Monad.Eff (kind Effect, Eff)
import Control.Monad.Eff.Exception (EXCEPTION)
import DOM (DOM)
import DOM.Event.Types (EventTarget, Event, EventType)
-- | A boxed function that can be used as an event listener. This is necessary
-- | due to the underling implementation of Eff functions.
foreign import data EventListener :: # Effect -> Type
-- | Creates an EventListener from a normal PureScript Eff function.
foreign import eventListener
:: forall eff a
. (Event -> Eff eff a)
-> EventListener eff
-- | Adds a listener to an event target. The boolean argument indicates whether
-- | the listener should be added for the "capture" phase.
foreign import addEventListener
:: forall eff
. EventType
-> EventListener (dom :: DOM | eff)
-> Boolean
-> EventTarget
-> Eff (dom :: DOM | eff) Unit
-- | Removes a listener to an event target. The boolean argument indicates
-- | whether the listener should be removed for the "capture" phase.
foreign import removeEventListener
:: forall eff
. EventType
-> EventListener (dom :: DOM | eff)
-> Boolean
-> EventTarget
-> Eff (dom :: DOM | eff) Unit
-- | Dispatches an event from an event target.
foreign import dispatchEvent
:: forall eff
. Event
-> EventTarget
-> Eff (dom :: DOM, exception :: EXCEPTION | eff) Boolean