https://github.com/thoughtbot/expirable
Manage values that expire after a period of time.
https://github.com/thoughtbot/expirable
elm elm-lang
Last synced: 7 months ago
JSON representation
Manage values that expire after a period of time.
- Host: GitHub
- URL: https://github.com/thoughtbot/expirable
- Owner: thoughtbot
- License: mit
- Created: 2018-06-29T19:19:10.000Z (over 7 years ago)
- Default Branch: main
- Last Pushed: 2021-09-24T16:06:40.000Z (about 4 years ago)
- Last Synced: 2025-03-24T06:54:38.975Z (8 months ago)
- Topics: elm, elm-lang
- Language: Elm
- Homepage: http://package.elm-lang.org/packages/thoughtbot/expirable/latest
- Size: 40 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Expirable
Manage values that expire after a period of time.
## Example
```elm
import Expirable exposing (Expirable)
type alias Model =
{ toastMessages : List (Expirable String)
}
type Msg
= DecrementToastMessages Time.Posix
initial : Model
initial =
{ toastMessages =
[ Expirable.build (Expirable.seconds 5) "Hi there"
, Expirable.build (Expirable.seconds 30) "This goes longer"
]
}
subscriptions : Model -> Sub Msg
subscriptions model =
Expirable.subscription DecrementToastMessages
update : Msg -> Model -> ( Model, Cmd Msg )
update msg model =
case msg of
DecrementToastMessages time ->
( { model
| toastMessages = Expirable.tickAll time model.toastMessages
}
, Cmd.none
)
```
## Development
To set up a working development environment, run:
```sh
yarn
```
Ensure that this project's `node_modules/.bin` is at the beginning
of your `$PATH`, ensuring that any local NPM packages have the
highest priority.
To ensure the package compiles:
```sh
yarn build
```
To run tests:
```sh
yarn test
```
## License
See the [LICENSE](/LICENSE) file.
## About thoughtbot

Expirable is maintained and funded by thoughtbot, inc.
The names and logos for thoughtbot are trademarks of thoughtbot, inc.
We love open source software!
See [our other projects][community] or
[hire us][hire] to design, develop, and grow your product.
[community]: https://thoughtbot.com/community?utm_source=github
[hire]: https://thoughtbot.com/hire-us?utm_source=github