@@ -4,7 +4,7 @@ import Prelude
44
55import Ace.Editor as Editor
66import Ace.EditSession as Session
7- import Ace.Halogen.Component (AceState (), AceQuery (), initialAceState )
7+ import Ace.Halogen.Component (AceState (), AceQuery (TextChanged, GetText ), initialAceState )
88import qualified Ace.Halogen.Component as Ace
99
1010import Control.Monad.Aff (Aff (), runAff )
@@ -14,7 +14,7 @@ import Control.Monad.Eff.Exception (throwException)
1414import Control.Plus (Plus )
1515
1616import Data.Functor.Coproduct (Coproduct ())
17- import Data.Maybe (Maybe (..))
17+ import Data.Maybe (Maybe (..), fromMaybe )
1818
1919import Halogen
2020import Halogen.Util (appendToBody , onLoad )
@@ -55,7 +55,7 @@ type MainEffects = HalogenEffects (random :: RANDOM, now :: Now, ref :: REF, ace
5555type MainAff = Aff MainEffects
5656
5757ui :: Component (StateP MainAff ) QueryP MainAff
58- ui = parentComponent render eval
58+ ui = parentComponent' render eval peek
5959 where
6060
6161 render :: State -> MainHtml MainAff
@@ -82,6 +82,16 @@ ui = parentComponent render eval
8282 eval (UpdateText next) = do
8383 pure next
8484
85+ peek :: Peek (ChildF AceSlot AceQuery ) State AceState Query AceQuery MainAff AceSlot
86+ peek (ChildF p q) =
87+ case q of
88+ TextChanged _ -> do
89+ text <- query AceSlot $ request GetText
90+ modify (_ { text = fromMaybe " " text })
91+ pure unit
92+ _ ->
93+ pure unit
94+
8595main :: Eff MainEffects Unit
8696main = runAff throwException (const (pure unit)) $ do
8797 app <- runUI ui (installedState initialState)
0 commit comments