diff options
author | eric <thul.eric@gmail.com> | 2015-08-11 21:23:46 -0400 |
---|---|---|
committer | eric <thul.eric@gmail.com> | 2015-08-11 21:23:46 -0400 |
commit | 7226ff961c104037e8e5d3705949e2e9d58a6727 (patch) | |
tree | 555547366ccadfe71689b95a6b16b855b6173364 /src/PursLoader/LoaderRef.purs | |
parent | eae2e182cec2d521166e5775294b52300c42f069 (diff) | |
parent | 07de44be15efb0ca9a2d1443ab1e91076a25409c (diff) | |
download | purs-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.purs | 40 |
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 @@ | |||
1 | module PursLoader.LoaderRef | ||
2 | ( LoaderRef() | ||
3 | , Loader() | ||
4 | , async | ||
5 | , cacheable | ||
6 | , query | ||
7 | , clearDependencies | ||
8 | , addDependency | ||
9 | , resourcePath | ||
10 | ) where | ||
11 | |||
12 | import Prelude (Unit()) | ||
13 | |||
14 | import Control.Monad.Eff (Eff()) | ||
15 | import Control.Monad.Eff.Exception (Error()) | ||
16 | |||
17 | import Data.Function (Fn3(), runFn3) | ||
18 | import Data.Maybe (Maybe(), fromMaybe, isJust) | ||
19 | |||
20 | data LoaderRef | ||
21 | |||
22 | foreign import data Loader :: ! | ||
23 | |||
24 | foreign 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 | |||
29 | async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit) | ||
30 | async ref = runFn3 asyncFn isJust fromMaybe ref | ||
31 | |||
32 | foreign import cacheable :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit | ||
33 | |||
34 | foreign import query :: LoaderRef -> String | ||
35 | |||
36 | foreign import clearDependencies :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit | ||
37 | |||
38 | foreign import resourcePath :: LoaderRef -> String | ||
39 | |||
40 | foreign import addDependency :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit | ||