Skip to content

Commit

Permalink
Use WrappedModel in search
Browse files Browse the repository at this point in the history
We need flags inside of search to make api calls later on.

Co-authored-by: Szymon Fiedler <[email protected]>
Co-authored-by: Paweł Pacana <[email protected]>
  • Loading branch information
3 people committed Mar 20, 2024
1 parent 017a919 commit 6183967
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
13 changes: 11 additions & 2 deletions ruby_event_store-browser/elm/src/Layout.elm
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,17 @@ update msg model =
case msg of
SearchMsg searchMsg ->
let
( newSearch, cmd ) =
Search.update searchMsg model.internal.search (goToStream model)
internal =
model.internal

search =
internal.search

( newSearchWrapped, cmd ) =
Search.update searchMsg (WrappedModel search model.key model.time model.flags) (goToStream model)

newSearch =
newSearchWrapped.internal
in
( { model | internal = Model newSearch }, Cmd.map SearchMsg cmd )

Expand Down
15 changes: 13 additions & 2 deletions ruby_event_store-browser/elm/src/Search.elm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Search exposing (..)
import Html exposing (..)
import Html.Attributes exposing (class, id, list, placeholder, value)
import Html.Events exposing (onInput, onSubmit)
import WrappedModel exposing (WrappedModel)


type alias Stream =
Expand All @@ -27,11 +28,21 @@ init =
}


update : Msg -> Model -> (String -> Cmd Msg) -> ( Model, Cmd Msg )
update : Msg -> WrappedModel Model -> (String -> Cmd Msg) -> ( WrappedModel Model, Cmd Msg )
update msg model onSubmit =
case msg of
StreamChanged stream ->
( { model | value = stream }, Cmd.none )
let
internal =
model.internal

updatedInternal =
{ internal | value = stream }

wrappedModel =
{ model | internal = updatedInternal }
in
( wrappedModel, Cmd.none )

GoToStream stream ->
( model, onSubmit stream )
Expand Down

0 comments on commit 6183967

Please sign in to comment.