Finished with editor main loop, including support for asynchronous searches

This commit is contained in:
Paul Chiusano 2015-02-03 18:24:34 -05:00
parent a7f1ebe9af
commit e29905eea0
2 changed files with 14 additions and 16 deletions

View File

@ -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)

View File

@ -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 =