initial commit
This commit is contained in:
28
src/Props.purs
Normal file
28
src/Props.purs
Normal file
@@ -0,0 +1,28 @@
|
||||
module Props where
|
||||
|
||||
import Prelude
|
||||
|
||||
|
||||
type Props = Array PropType
|
||||
data PropType = Int String
|
||||
| String String
|
||||
| Number String
|
||||
-- | Object String
|
||||
|
||||
toProp :: PropType -> String
|
||||
toProp (Int s) = s
|
||||
toProp (String s) = s
|
||||
toProp (Number s) = s
|
||||
|
||||
toProps :: Array PropType -> Array String
|
||||
toProps = map toProp
|
||||
|
||||
|
||||
-- class Proppable a where
|
||||
-- toProps :: a -> Array String
|
||||
--
|
||||
-- --instance propProps :: Proppable Props
|
||||
-- -- toProps p = Arr.fromFoldable $ Record.keys (RProxy :: RProxy Props)
|
||||
--
|
||||
-- type PropsRecord = Record Props
|
||||
-- props = Arr.fromFoldable $ Record.keys (RProxy :: RProxy Props)
|
||||
50
src/vueHooks.js
Normal file
50
src/vueHooks.js
Normal file
@@ -0,0 +1,50 @@
|
||||
"use strict";
|
||||
|
||||
var comp = require("@vue/composition-api");
|
||||
|
||||
// exports.onMounted = vue.onMounted
|
||||
exports.onBeforeMount = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onMounted = function(eff) {
|
||||
return function() {
|
||||
comp.onMounted(eff)
|
||||
}
|
||||
}
|
||||
exports.onBeforeUpdate = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onUpdated = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onBeforeUnmount = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onUnmounted = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onActivated = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onDeactivated = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
exports.onErrorCaptured = function(eff) {
|
||||
return function() {
|
||||
comp.on(eff)
|
||||
}
|
||||
}
|
||||
35
src/vueHooks.purs
Normal file
35
src/vueHooks.purs
Normal file
@@ -0,0 +1,35 @@
|
||||
module Effect.Vue.Hooks
|
||||
( onBeforeMount
|
||||
, onMounted
|
||||
, onBeforeUpdate
|
||||
, onUpdated
|
||||
, onBeforeUnmount
|
||||
, onUnmounted
|
||||
, onActivated
|
||||
, onDeactivated
|
||||
, onErrorCaptured
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
import Effect.Class (class MonadEffect, liftEffect)
|
||||
|
||||
-- These lifecycle registration methods can only be used during the invocation of a setup hook.
|
||||
-- It automatically figures out the current instance calling the setup hook using internal global state.
|
||||
-- It is intentionally designed this way to reduce friction when extracting logic into external functions.
|
||||
|
||||
-- foreign import onMounted :: forall m a. MonadEffect m => a -> m Unit
|
||||
foreign import onBeforeMount :: Effect Unit -> Effect Unit
|
||||
foreign import onMounted :: Effect Unit -> Effect Unit
|
||||
foreign import onBeforeUpdate :: Effect Unit -> Effect Unit
|
||||
foreign import onUpdated :: Effect Unit -> Effect Unit
|
||||
foreign import onBeforeUnmount :: Effect Unit -> Effect Unit
|
||||
foreign import onUnmounted :: Effect Unit -> Effect Unit
|
||||
foreign import onActivated :: Effect Unit -> Effect Unit
|
||||
foreign import onDeactivated :: Effect Unit -> Effect Unit
|
||||
foreign import onErrorCaptured :: Effect Unit -> Effect Unit
|
||||
|
||||
-- What about
|
||||
-- onRenderTracked
|
||||
-- onRenderTriggered
|
||||
-- ?
|
||||
57
src/vueRef.js
Normal file
57
src/vueRef.js
Normal file
@@ -0,0 +1,57 @@
|
||||
"use strict";
|
||||
|
||||
var comp = require("@vue/composition-api");
|
||||
|
||||
// Ref
|
||||
|
||||
exports.vReturn = function(dict) {
|
||||
return function() {
|
||||
return dict
|
||||
}
|
||||
}
|
||||
|
||||
exports.new = function (val) {
|
||||
return function () {
|
||||
return comp.ref(val);
|
||||
};
|
||||
};
|
||||
|
||||
exports.read = function (ref) {
|
||||
return function () {
|
||||
return ref.value;
|
||||
};
|
||||
};
|
||||
|
||||
exports.modifyImpl = function (f) {
|
||||
return function (ref) {
|
||||
return function () {
|
||||
var t = f(ref.value);
|
||||
ref.value = t.state;
|
||||
return t.value;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
exports.write = function (val) {
|
||||
return function (ref) {
|
||||
return function () {
|
||||
ref.value = val;
|
||||
return {};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Computed
|
||||
|
||||
exports.computed = function (fn) {
|
||||
return function () {
|
||||
return comp.computed(fn)
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// to seperate module
|
||||
|
||||
// exports.setup = function (props) {
|
||||
// }
|
||||
57
src/vueRef.purs
Normal file
57
src/vueRef.purs
Normal file
@@ -0,0 +1,57 @@
|
||||
module Effect.Vue.Ref
|
||||
( Ref
|
||||
, new
|
||||
, read
|
||||
, modify'
|
||||
, modify
|
||||
, modify_
|
||||
, write
|
||||
, vReturn
|
||||
, computed
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Effect (Effect)
|
||||
|
||||
-- data Ref a = Ref a
|
||||
-- foreign import ref :: forall a b. a -> Ref b
|
||||
-- foreign import refVal :: forall a b. Ref a -> a
|
||||
|
||||
|
||||
foreign import vReturn :: forall a b. a -> Effect b
|
||||
|
||||
|
||||
-- | A value of type `Ref a` represents a mutable reference
|
||||
-- | which holds a value of type `a`.
|
||||
foreign import data Ref :: Type -> Type
|
||||
|
||||
-- | Create a new mutable reference containing the specified value.
|
||||
foreign import new :: forall s. s -> Effect (Ref s)
|
||||
|
||||
-- | Read the current value of a mutable reference
|
||||
foreign import read :: forall s. Ref s -> Effect s
|
||||
|
||||
-- | Update the value of a mutable reference by applying a function
|
||||
-- | to the current value.
|
||||
modify' :: forall s b. (s -> { state :: s, value :: b }) -> Ref s -> Effect b
|
||||
modify' = modifyImpl
|
||||
|
||||
foreign import modifyImpl :: forall s b. (s -> { state :: s, value :: b }) -> Ref s -> Effect b
|
||||
|
||||
-- | Update the value of a mutable reference by applying a function
|
||||
-- | to the current value. The updated value is returned.
|
||||
modify :: forall s. (s -> s) -> Ref s -> Effect s
|
||||
modify f = modify' \s -> let s' = f s in { state: s', value: s' }
|
||||
|
||||
modify_ :: forall s. (s -> s) -> Ref s -> Effect Unit
|
||||
modify_ f s = void $ modify f s
|
||||
|
||||
-- | Update the value of a mutable reference to the specified value.
|
||||
foreign import write :: forall s. s -> Ref s -> Effect Unit
|
||||
|
||||
|
||||
-- |
|
||||
-- | COMPUTED
|
||||
-- |
|
||||
|
||||
foreign import computed :: forall a b. Effect a -> Effect (Ref b)
|
||||
Reference in New Issue
Block a user