diff --git a/editor/src/Elmz/Signal.elm b/editor/src/Elmz/Signal.elm index 3a6c4fb4e..e79052c2f 100644 --- a/editor/src/Elmz/Signal.elm +++ b/editor/src/Elmz/Signal.elm @@ -21,8 +21,8 @@ import Time (Time) accumulateWhen : Signal Bool -> Signal a -> Signal (List a) accumulateWhen cond a = foldpWhen cond (::) [] a |> map List.reverse -asyncUpdate : (Signal req -> Signal (Maybe (model -> model))) - -> Signal (model -> (model, Maybe req)) +asyncUpdate : (Signal req -> Signal (model -> model)) + -> Signal (model -> (Maybe req, model)) -> req -> model -> Signal model @@ -34,12 +34,11 @@ asyncUpdate eval actions req0 model0 = err = "Unpossible! User interaction and async response event cannot co-occur." update model event = case event of (Nothing, Nothing) -> send ignore model0 - (Just Nothing, Just action) -> case action model of - (model, Nothing) -> send models model - (model, Just req) -> send models model `Execute.combine` send reqs req - (Just (Just response), Just action) -> Debug.crash err - (Just (Just response), Nothing) -> - send models (response model) + (Just response, Just action') -> Debug.crash err + (Nothing, Just action) -> case action model of + (Nothing, model) -> send models model + (Just req, model) -> send models model `Execute.combine` send reqs req + (Just response, Nothing) -> send models (response model) msgs = map2 update (subscribe models) (oneOrBoth responses actions) in sampleOn (subscribe models) <| map2 always (subscribe models) diff --git a/editor/src/Unison/Editor.elm b/editor/src/Unison/Editor.elm index f2bdc1647..3f039567e 100644 --- a/editor/src/Unison/Editor.elm +++ b/editor/src/Unison/Editor.elm @@ -173,14 +173,13 @@ actions ctx = Signal.map moveMouse ctx.mouse `merge` Signal.map (resize (Just (Signal.send ctx.channel))) steadyWidth --- can do search : Signal Search -> Signal (Model -> Model) --- and then can just map2 the result of search and models to get final output models!!! - --- models : Inputs -> Model -> Signal Model --- models ctx model0 = Signal.foldp (<|) model0 (actions ctx) - --- derived actions handled elsewhere? --- can listen for explorer becoming active - this can trigger http request to fetch +models : Inputs -> (Signal Request -> Signal (Model -> Model)) -> Model -> Signal Model +models ctx search model0 = + Signals.asyncUpdate + search + (actions ctx) + { term = model0.term, path = [], query = Nothing } + model0 view : Model -> Element view model =