Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update README.md #16

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ addResetCounter =

addResetCounterVariant : Rule
addResetCounterVariant =
Install.TypeVariant.makeRule "Msg" "Msg" "ResetCounter"
Install.TypeVariant.makeRule "Counter" "Msg" "ResetCounter"

addResetCounterClause : Rule
addResetCounterClause =
Expand Down Expand Up @@ -92,6 +92,7 @@ update msg model =
- **Install.FieldInTypeAlias**: Add a field to a specified type alias in a specified module. For more details, see the [docs](https://package.elm-lang.org/packages/jxxcarlson/elm-review-codeinstaller/latest/Install-FieldInTypeAlias).
- **Install.Initializer**: Add a field to the body of an initializer function where the return value is of the form `( Model, Cmd msg )`. For more details, see the [docs](https://package.elm-lang.org/packages/jxxcarlson/elm-review-codeinstaller/latest/Install-Initializer).
- **Install.TypeVariant**: Add a variant to a specified type in a specified module. For more details, see the [docs](https://package.elm-lang.org/packages/jxxcarlson/elm-review-codeinstaller/latest/Install-TypeVariant).
- **Install.Function**: Replace a function in a given module with a new implementation or add that function definition if it is not present in the module. For more details, see the [docs](https://package.elm-lang.org/packages/jxxcarlson/elm-review-codeinstaller/latest/Install-Function).

## Try it out
To test the review code in its current state, try running this in a clean Lamdera project:
Expand Down
27 changes: 13 additions & 14 deletions preview/src/ReviewConfig.elm
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,29 @@ when inside the directory containing this file.

-}

import Install.TypeVariant
import Install.FieldInTypeAlias
import Install.Initializer
import Install.ClauseInCase
import Install.FieldInTypeAlias
import Install.Function
import Install.Initializer
import Install.TypeVariant
import Review.Rule exposing (Rule)



config : List Rule
config =
[
Install.TypeVariant.makeRule "Types" "ToBackend" "CounterReset"
, Install.TypeVariant.makeRule "Types" "FrontendMsg" "Reset"
, Install.ClauseInCase.init "Frontend" "update" "Reset" "( { model | counter = 0 }, sendToBackend CounterReset )"
[ Install.TypeVariant.makeRule "Types" "ToBackend" "CounterReset"
, Install.TypeVariant.makeRule "Types" "FrontendMsg" "Reset"
, Install.ClauseInCase.init "Frontend" "update" "Reset" "( { model | counter = 0 }, sendToBackend CounterReset )"
|> Install.ClauseInCase.withInsertAfter "Increment"
|> Install.ClauseInCase.makeRule
, Install.ClauseInCase.init "Backend" "updateFromFrontend" "CounterReset" "( { model | counter = 0 }, broadcast (CounterNewValue 0 clientId) )"
, Install.ClauseInCase.init "Backend" "updateFromFrontend" "CounterReset" "( { model | counter = 0 }, broadcast (CounterNewValue 0 clientId) )"
|> Install.ClauseInCase.makeRule
, Install.Function.init ["Frontend"] "view" viewFunction |>Install.Function.makeRule

, Install.Function.init [ "Frontend" ] "view" viewFunction |> Install.Function.makeRule
]

viewFunction = """view model =

viewFunction =
"""view model =
Html.div [ style "padding" "50px" ]
[ Html.button [ onClick Increment ] [ text "+" ]
, Html.div [ style "padding" "10px" ] [ Html.text (String.fromInt model.counter) ]
Expand All @@ -44,12 +43,12 @@ viewFunction = """view model =
]"""


viewFunction2 = """view model =
viewFunction2 =
"""view model =
Html.div [ style "padding" "50px" ]
[ Html.button [ onClick Increment ] [ text "+" ]
, Html.div [ style "padding" "10px" ] [ Html.text (String.fromInt model.counter) ]
, Html.button [ onClick Decrement ] [ text "-" ]
, Html.div [ style "padding-top" "15px", style "padding-bottom" "15px" ] [ Html.text "Click me then refresh me!" ]
, Html.button [ onClick Reset ] [ text "Reset" ]
]"""

Loading