aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/PursLoader/LoaderRef.purs
diff options
context:
space:
mode:
authoreric <thul.eric@gmail.com>2015-08-11 21:23:46 -0400
committereric <thul.eric@gmail.com>2015-08-11 21:23:46 -0400
commit7226ff961c104037e8e5d3705949e2e9d58a6727 (patch)
tree555547366ccadfe71689b95a6b16b855b6173364 /src/PursLoader/LoaderRef.purs
parenteae2e182cec2d521166e5775294b52300c42f069 (diff)
parent07de44be15efb0ca9a2d1443ab1e91076a25409c (diff)
downloadpurs-loader-7226ff961c104037e8e5d3705949e2e9d58a6727.tar.gz
purs-loader-7226ff961c104037e8e5d3705949e2e9d58a6727.tar.zst
purs-loader-7226ff961c104037e8e5d3705949e2e9d58a6727.zip
Merge pull request #27 from ethul/topic/issue-26
Topic/issue 26
Diffstat (limited to 'src/PursLoader/LoaderRef.purs')
-rw-r--r--src/PursLoader/LoaderRef.purs40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/PursLoader/LoaderRef.purs b/src/PursLoader/LoaderRef.purs
new file mode 100644
index 0000000..33c4f7e
--- /dev/null
+++ b/src/PursLoader/LoaderRef.purs
@@ -0,0 +1,40 @@
1module PursLoader.LoaderRef
2 ( LoaderRef()
3 , Loader()
4 , async
5 , cacheable
6 , query
7 , clearDependencies
8 , addDependency
9 , resourcePath
10 ) where
11
12import Prelude (Unit())
13
14import Control.Monad.Eff (Eff())
15import Control.Monad.Eff.Exception (Error())
16
17import Data.Function (Fn3(), runFn3)
18import Data.Maybe (Maybe(), fromMaybe, isJust)
19
20data LoaderRef
21
22foreign import data Loader :: !
23
24foreign import asyncFn :: forall eff a. Fn3 (Maybe Error -> Boolean)
25 (Error -> Maybe Error -> Error)
26 LoaderRef
27 (Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit))
28
29async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit)
30async ref = runFn3 asyncFn isJust fromMaybe ref
31
32foreign import cacheable :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
33
34foreign import query :: LoaderRef -> String
35
36foreign import clearDependencies :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
37
38foreign import resourcePath :: LoaderRef -> String
39
40foreign import addDependency :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit