packages feed

react-flux 1.0.5 → 1.0.6

raw patch · 6 files changed

+22/−13 lines, 6 files

Files

ChangeLog.md view
@@ -1,3 +1,11 @@+# 1.0.6++* Fix a rare bug in stateful view event handlers: occasionally deepseq was not called and so there+  was a race between react reusing the event and the haskell code extracting data from the event.+* Add overlapping pragmas to the Callback instances, making the `callback` function easier to use+  without requiring explicit type signatures.  This change is backwards compatible.+* Some minor documentation updates.+ # 1.0.5  * Fix a bug in the `jsonAjax` implementation: the request body was not properly JSON encoded.
react-flux.cabal view
@@ -1,5 +1,5 @@ name:                react-flux-version:             1.0.5+version:             1.0.6 synopsis:            A binding to React based on the Flux application architecture for GHCJS category:            Web homepage:            https://bitbucket.org/wuzzeb/react-flux
src/React/Flux/Combinators.hs view
@@ -49,13 +49,13 @@ #endif  -- | A wrapper around 'foreignClass' that looks up the class on the `window`.  I use it for several--- third-party react components.  For example, with <https://github.com/rackt/react-modal--- react-modal>, assuming `window.Modal` contains the definition of the classes,+-- third-party react components.  For example, with <https://github.com/reactjs/react-modal react-modal>,+-- assuming `window.ReactModal` contains the definition of the class, ----- >foreign_ "Modal" [ "isOpen" @= isModelOpen myProps--- >                 , callback "onRequestClose" $ dispatch closeModel--- >                 , "style" @= Aeson.object [ "overlay" @= Aeson.object ["left" $= "50%", "right" $= "50%"]]--- >                 ] $ do+-- >foreign_ "ReactModal" [ "isOpen" @= isModelOpen myProps+-- >                      , callback "onRequestClose" $ dispatch closeModel+-- >                      , "style" @= Aeson.object [ "overlay" @= Aeson.object ["left" $= "50%", "right" $= "50%"]]+-- >                      ] $ do -- >    h1_ "Hello, World!" -- >    p_ "...." --
src/React/Flux/Lifecycle.hs view
@@ -41,6 +41,7 @@ import React.Flux.Internal import React.Flux.Views import React.Flux.DOM (div_)+import Control.DeepSeq (NFData)  #ifdef __GHCJS__ import Control.Monad.Writer@@ -111,7 +112,7 @@ -- >            { lRender = \state props -> ... -- >            , lComponentWillMount = \propsAndState setStateFn -> ... -- >            }-defineLifecycleView :: (Typeable props, Typeable state)+defineLifecycleView :: (Typeable props, Typeable state, NFData state)               => String -> state -> LifecycleViewConfig props state -> ReactView props  #ifdef __GHCJS__
src/React/Flux/PropertiesAndEvents.hs view
@@ -144,10 +144,10 @@ instance CallbackFunction ViewEventHandler ViewEventHandler where     applyFromArguments _ _ h = return h -instance CallbackFunction (StatefulViewEventHandler s) (StatefulViewEventHandler s) where+instance {-# OVERLAPPING #-} CallbackFunction (StatefulViewEventHandler s) (StatefulViewEventHandler s) where     applyFromArguments _ _ h = return h -instance (FromJSVal a, CallbackFunction handler b) => CallbackFunction handler (a -> b) where+instance {-# OVERLAPPABLE #-} (FromJSVal a, CallbackFunction handler b) => CallbackFunction handler (a -> b) where #if __GHCJS__     applyFromArguments args k f = do         ma <- fromJSVal $ if k >= JSA.length args then nullRef else JSA.index k args
src/React/Flux/Views.hs view
@@ -223,7 +223,7 @@ -- > -- >todoTextInput_ :: TextInputArgs -> ReactElementM eventHandler () -- >todoTextInput_ args = view todoTextInput args mempty-defineStatefulView :: (Typeable state, Typeable props)+defineStatefulView :: (Typeable state, NFData state, Typeable props)                => String -- ^ A name for this view, used only for debugging/console logging                -> state -- ^ The initial state                -> (state -> props -> ReactElementM (StatefulViewEventHandler state) ()) -- ^ The rendering function@@ -238,7 +238,7 @@     ReactView <$> js_createStatefulView (toJSString name) initialRef renderCb  -- | Transform a stateful view event handler to a raw event handler-runStateViewHandler :: Typeable state+runStateViewHandler :: (Typeable state, NFData state)                     => ReactThis state props -> StatefulViewEventHandler state -> IO () runStateViewHandler this handler = do     st <- js_ReactGetState this >>= parseExport@@ -248,7 +248,7 @@     case mNewState of         Nothing -> return ()         Just newState -> do-            newStateRef <- export newState+            newStateRef <- newState `deepseq` export newState             js_ReactUpdateAndReleaseState this newStateRef      -- nothing above here should block, so the handler callback should still be running syncronous,