https://github.com/iodevs/elm-history
A history pattern for Elm
https://github.com/iodevs/elm-history
elm hacktoberfest
Last synced: 10 months ago
JSON representation
A history pattern for Elm
- Host: GitHub
- URL: https://github.com/iodevs/elm-history
- Owner: iodevs
- License: other
- Created: 2018-10-02T19:21:56.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-10-05T12:33:57.000Z (over 7 years ago)
- Last Synced: 2025-02-01T07:43:47.544Z (12 months ago)
- Topics: elm, hacktoberfest
- Language: Elm
- Homepage:
- Size: 8.79 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# elm-history
This library helps with keeping history of states of your variables.
For example, you defined a width of some div (elm-css or style or ...) and
this width has been changed by user's action. After that you want to have
same width of div as before user's action.
Install package usually a way (elm-0.19):
```
elm install iodevs/elm-history
```
## Usage:
```haskell
import History exposing (History, create, forward, rewind, rewindAll)
boxWidth : History String
boxWidth =
create "200px"
newBoxWidth =
boxWidth
|> forward "300px" -- History "300px" ["200px"]
|> forward "400px" -- History "400px" ["300px", "200px"]
|> forward "500px" -- History "500px" ["400px", "300px", "200px"]
|> rewind -- History "400px" ["300px","200px"]
|> rewindAll -- History "200px" []
|> current -- "200px"
```