module React.Class
( ReactClass(..)
, createClass
) where
import Data.IORef
import React.Anim
import React.Imports
import React.Types
import Haste
import Haste.JSON
import Haste.Prim
data ReactClass ty = ReactClass
{ classRender :: ClassState ty -> React ty ()
, classTransition :: ClassState ty
-> Signal ty
-> (ClassState ty, [AnimConfig ty])
, foreignClass :: ForeignClass
, stateRef :: IORef (ClassState ty)
, animRef :: IORef (AnimationState ty)
, runningAnimRef :: IORef [RunningAnim ty]
, transitionRef :: IORef [Signal ty]
}
createClass :: (ClassState ty -> React ty ())
-> (ClassState ty -> Signal ty -> (ClassState ty, [AnimConfig ty]))
-> ClassState ty
-> AnimationState ty
-> [Signal ty]
-> IO (ReactClass ty)
createClass render transition initialState initialAnim initialTrans = do
foreignClass <- js_createClass $ toPtr render
stateRef <- newIORef initialState
animRef <- newIORef initialAnim
runningAnimRef <- newIORef []
transitionRef <- newIORef initialTrans
return $ ReactClass
render
transition
foreignClass
stateRef
animRef
runningAnimRef
transitionRef