aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/LoaderRef.purs
diff options
context:
space:
mode:
Diffstat (limited to 'src/LoaderRef.purs')
-rw-r--r--src/LoaderRef.purs74
1 files changed, 0 insertions, 74 deletions
diff --git a/src/LoaderRef.purs b/src/LoaderRef.purs
deleted file mode 100644
index f1efa04..0000000
--- a/src/LoaderRef.purs
+++ /dev/null
@@ -1,74 +0,0 @@
1module PursLoader.LoaderRef
2 ( LoaderRef()
3 , Loader()
4 , async
5 , cacheable
6 , query
7 , clearDependencies
8 , addDependency
9 , resourcePath
10 ) where
11
12import Control.Monad.Eff (Eff())
13import Control.Monad.Eff.Exception (Error())
14
15import Data.Function (Fn3(), runFn3)
16import Data.Maybe (Maybe(), fromMaybe, isJust)
17
18data LoaderRef
19
20foreign import data Loader :: !
21
22foreign import asyncFn """
23function asyncFn(isJust, fromMaybe, ref){
24 return function(){
25 var callback = ref.async();
26 return function(error){
27 return function(value){
28 return function(){
29 return isJust(error) ? callback(fromMaybe(new Error())(error))
30 : callback(null, value);
31 };
32 };
33 };
34 };
35}""" :: forall eff a. Fn3 (Maybe Error -> Boolean)
36 (Error -> Maybe Error -> Error)
37 LoaderRef
38 (Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit))
39
40async :: forall eff a. LoaderRef -> Eff (loader :: Loader | eff) (Maybe Error -> a -> Eff (loader :: Loader | eff) Unit)
41async ref = runFn3 asyncFn isJust fromMaybe ref
42
43foreign import cacheable """
44function cacheable(ref){
45 return function(){
46 return ref.cacheable && ref.cacheable();
47 };
48}""" :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
49
50foreign import query """
51function query(ref){
52 return ref.query;
53}""" :: LoaderRef -> String
54
55foreign import clearDependencies """
56function clearDependencies(ref){
57 return function(){
58 return ref.clearDependencies();
59 };
60}""" :: forall eff. LoaderRef -> Eff (loader :: Loader | eff) Unit
61
62foreign import resourcePath """
63function resourcePath(ref){
64 return ref.resourcePath;
65}""" :: LoaderRef -> String
66
67foreign import addDependency """
68function addDependency(ref){
69 return function(dep){
70 return function(){
71 return ref.addDependency(dep);
72 };
73 };
74}""" :: forall eff. LoaderRef -> String -> Eff (loader :: Loader | eff) Unit